Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/LAA-Software-Engineering/golang-rest-api-template
/ functions
Functions
337 in github.com/LAA-Software-Engineering/golang-rest-api-template
⨍
Functions
337
◇
Types & classes
38
↓ 1 callers
Function
RequestContextTimeoutFromEnv
RequestContextTimeoutFromEnv is like RequestContextTimeout with a duration from REQUEST_CONTEXT_TIMEOUT (Go duration syntax). Empty uses 60s. "0", "of
pkg/middleware/request_timeout.go:35
↓ 1 callers
Function
Security
()
pkg/middleware/security.go:8
↓ 1 callers
Function
SetupMongoDB
SetupMongoDB connects to MongoDB and returns the application logs collection. It reads MONGODB_URI (e.g. mongodb://mongo:27017 under Docker Compose);
pkg/database/mongo.go:24
↓ 1 callers
Method
UpdateFields
(id uint, title, author string)
pkg/repository/book.go:12
↓ 1 callers
Function
Xss
()
pkg/middleware/xss.go:8
↓ 1 callers
Function
bcryptCostForPasswordHashing
bcryptCostForPasswordHashing returns the bcrypt cost for HashPassword. BCRYPT_COST overrides the default (12); it must parse as an integer in [minBcry
pkg/auth/auth.go:112
↓ 1 callers
Method
cacheGeneration
(ctx context.Context)
pkg/service/book_service.go:46
↓ 1 callers
Function
constantTimeAPIKeyEqual
constantTimeAPIKeyEqual reports whether provided equals secret using crypto/subtle. Length is folded into the compared buffers so a single ConstantTim
pkg/middleware/api_key.go:66
↓ 1 callers
Function
delete_book
(book_id, jwt_token)
tests/e2e.py:102
↓ 1 callers
Method
enqueue
(doc bson.M)
pkg/middleware/logger.go:54
↓ 1 callers
Function
get_books
(jwt_token)
tests/e2e.py:60
↓ 1 callers
Function
get_jwt_token
()
tests/e2e.py:24
↓ 1 callers
Function
ignorableZapSyncErr
@title golang-rest-api-template @version 1.0 @description Go/Gin REST API template: books CRUD, register/login, Redis-backed lis
cmd/server/main.go:48
↓ 1 callers
Function
maxRequestBodyBytesFromEnv
maxRequestBodyBytesFromEnv returns REQUEST_MAX_BODY_BYTES or the middleware default (1 MiB). Invalid or non-positive values panic at process startup.
pkg/api/router.go:89
↓ 1 callers
Function
newMongoAccessLogQueue
(collection *mongo.Collection, logger *zap.Logger)
pkg/middleware/logger.go:30
↓ 1 callers
Function
newRequestID
()
pkg/middleware/request_id.go:18
↓ 1 callers
Function
parseOffsetLimit
(c *gin.Context)
pkg/api/books.go:59
↓ 1 callers
Function
patch_book
(book_id, jwt_token, payload: dict)
tests/e2e.py:91
↓ 1 callers
Function
readyzHandler
(db *gorm.DB, redisClient cache.Cache, mongoCol *mongo.Collection)
pkg/api/probes.go:31
↓ 1 callers
Function
registerProbeRoutes
registerProbeRoutes mounts Kubernetes-style liveness and readiness endpoints. They are registered before request logging, rate limiting, and the /api/
pkg/api/probes.go:22
↓ 1 callers
Function
setupSQLiteDB
(t *testing.T)
pkg/database/db_test.go:14
↓ 1 callers
Function
update_book
(book_id, jwt_token)
tests/e2e.py:80
↓ 1 callers
Method
worker
()
pkg/middleware/logger.go:43
Method
Create
(user *models.User)
pkg/service/user_service_test.go:31
Method
Create
(book *models.Book)
pkg/service/book_service_test.go:36
Method
Create
(user *models.User)
pkg/repository/user.go:8
Method
Create
Create mocks base method.
pkg/repository/mock_persistence.go:44
Method
Create
Create indicates an expected call of Create.
pkg/repository/mock_persistence.go:52
Method
Create
Create mocks base method.
pkg/repository/mock_persistence.go:156
Method
Create
Create indicates an expected call of Create.
pkg/repository/mock_persistence.go:164
Method
CreateBook
CreateBook godoc @Summary Create a new book @Description Create a new book with the given input data @Tags books @Security ApiKeyAuth @Security JwtAut
pkg/api/books.go:165
Method
Del
(context.Context, ...string)
pkg/cache/cache.go:25
Method
Del
Del mocks base method.
pkg/cache/cache_mock.go:46
Method
Del
Del indicates an expected call of Del.
pkg/cache/cache_mock.go:58
Method
DeleteBook
DeleteBook godoc @Summary Delete a book by ID @Description Delete the book with the given ID @Tags books @Security ApiKeyAuth @Security JwtAuth @Produ
pkg/api/books.go:325
Method
DeleteByID
(id uint)
pkg/service/book_service_test.go:64
Method
DeleteByID
DeleteByID mocks base method.
pkg/repository/mock_persistence.go:58
Method
DeleteByID
DeleteByID indicates an expected call of DeleteByID.
pkg/repository/mock_persistence.go:66
Method
FindBook
(c *gin.Context)
pkg/api/books.go:31
Method
FindBook
FindBook godoc @Summary Find a book by ID @Description Get details of a book by its ID @Tags books @Security ApiKeyAuth @Produce json @Param id path s
pkg/api/books.go:194
Method
FindBooks
(c *gin.Context)
pkg/api/books.go:29
Method
FindBooks
FindBooks godoc @Summary Get all books with pagination @Description Get a list of all books with optional pagination. List entries are keyed by a mono
pkg/api/books.go:127
Method
FindByUsername
(username string)
pkg/service/user_service_test.go:24
Method
FindByUsername
FindByUsername mocks base method.
pkg/repository/mock_persistence.go:170
Method
FindByUsername
FindByUsername indicates an expected call of FindByUsername.
pkg/repository/mock_persistence.go:179
Method
FirstByID
(id uint)
pkg/service/book_service_test.go:43
Method
FirstByID
FirstByID mocks base method.
pkg/repository/mock_persistence.go:72
Method
FirstByID
FirstByID indicates an expected call of FirstByID.
pkg/repository/mock_persistence.go:81
Method
Get
Get indicates an expected call of Get.
pkg/cache/cache_mock.go:73
Method
Healthcheck
@BasePath /api/v1 Healthcheck godoc @Summary ping example @Schemes @Description do ping @Tags example @Accept json @Produce json @Success 200 {object}
pkg/api/books.go:111
Method
Incr
Incr mocks base method.
pkg/cache/cache_mock.go:79
Method
Incr
Incr indicates an expected call of Incr.
pkg/cache/cache_mock.go:87
Method
List
(offset, limit int)
pkg/service/book_service_test.go:29
Method
List
List mocks base method.
pkg/repository/mock_persistence.go:87
Method
List
List indicates an expected call of List.
pkg/repository/mock_persistence.go:96
Method
LoginHandler
(c *gin.Context)
pkg/api/user.go:18
Method
LoginHandler
@BasePath /api/v1 LoginHandler godoc @Summary Authenticate a user @Schemes @Description Authenticates a user using username and password, returns a JW
pkg/api/user.go:47
Method
PatchBook
PatchBook godoc @Summary Partially update a book by ID (PATCH) @Description Updates only fields present in the JSON body (at least one of title or aut
pkg/api/books.go:276
Method
PatchFields
(id uint, title, author *string)
pkg/service/book_service_test.go:57
Method
PatchFields
PatchFields mocks base method.
pkg/repository/mock_persistence.go:102
Method
PatchFields
PatchFields indicates an expected call of PatchFields.
pkg/repository/mock_persistence.go:111
Method
RegisterHandler
(c *gin.Context)
pkg/api/user.go:19
Method
RegisterHandler
RegisterHandler godoc @Summary Register a new user @Schemes http @Description Registers a new user with the given username and password @Tags user @Se
pkg/api/user.go:82
Method
Set
Set mocks base method.
pkg/cache/cache_mock.go:93
Method
Set
Set indicates an expected call of Set.
pkg/cache/cache_mock.go:101
Function
TestAPIKeyAuthConcurrentValidRequests
(t *testing.T)
pkg/middleware/api_key_test.go:86
Function
TestAPIKeyAuthMissingHeader
(t *testing.T)
pkg/middleware/api_key_test.go:64
Function
TestAPIKeyAuthSecretNotConfiguredReturns503
(t *testing.T)
pkg/middleware/api_key_test.go:72
Function
TestAPIKeyAuthValidKey
(t *testing.T)
pkg/middleware/api_key_test.go:34
Function
TestAPIKeyAuthWrongKey
(t *testing.T)
pkg/middleware/api_key_test.go:43
Function
TestAPIKeyAuthWrongLengthRejected
(t *testing.T)
pkg/middleware/api_key_test.go:55
Function
TestAbort
(t *testing.T)
pkg/httperr/httperr_test.go:24
Function
TestBookWriteRoutesConcurrentAuthorizedRequests
(t *testing.T)
pkg/api/book_routes_auth_test.go:189
Function
TestBookWriteRoutesRejectTamperedJWT
(t *testing.T)
pkg/api/book_routes_auth_test.go:155
Function
TestBookWriteRoutesRequireAPIKeyAndJWT
(t *testing.T)
pkg/api/book_routes_auth_test.go:37
Function
TestBooksListDataCacheKey
(t *testing.T)
pkg/service/book_service_test.go:71
Function
TestConfigureConnPoolSQLite
(t *testing.T)
pkg/database/db_test.go:24
Function
TestConfigureTrustedProxiesAllowsForwardedFromTrustedPeer
(t *testing.T)
pkg/api/router_trusted_proxies_test.go:39
Function
TestConfigureTrustedProxiesInvalidEnvReturnsError
(t *testing.T)
pkg/api/router_trusted_proxies_test.go:31
Function
TestConfigureTrustedProxiesNilIgnoresForwardedFor
(t *testing.T)
pkg/api/router_trusted_proxies_test.go:12
Function
TestCreateBook
(t *testing.T)
pkg/api/books_test.go:692
Function
TestCreateBookBindError
(t *testing.T)
pkg/api/books_test.go:241
Function
TestCreateBookBumpsGenerationWhenRedis
(t *testing.T)
pkg/service/book_service_test.go:247
Function
TestCreateBookCacheIncrError
(t *testing.T)
pkg/api/books_test.go:281
Function
TestCreateBookDatabaseError
(t *testing.T)
pkg/api/books_test.go:208
Function
TestCreateBookNoIncrWhenNilRedis
(t *testing.T)
pkg/service/book_service_test.go:267
Function
TestCreateBookRequiresAuthContext
(t *testing.T)
pkg/api/books_test.go:263
Function
TestCreatedStructEnvelope
(t *testing.T)
pkg/httpresp/httpresp_test.go:26
Function
TestDeleteBook
(t *testing.T)
pkg/api/books_test.go:810
Function
TestDeleteBookBumpsGeneration
(t *testing.T)
pkg/service/book_service_test.go:342
Function
TestDeleteBookBumpsListCacheGen
(t *testing.T)
pkg/api/books_test.go:585
Function
TestDeleteBookDatabaseErrorOnDelete
(t *testing.T)
pkg/api/books_test.go:834
Function
TestDeleteBookInvalidID
(t *testing.T)
pkg/api/books_test.go:615
Function
TestDeleteBookNotFound
(t *testing.T)
pkg/api/books_test.go:634
Function
TestDeleteBookWrongOwner
(t *testing.T)
pkg/service/book_service_test.go:384
Function
TestErrUserUsernameConflictIsDistinct
(t *testing.T)
pkg/repository/repository_test.go:25
Function
TestFindBook
(t *testing.T)
pkg/api/books_test.go:732
Function
TestFindBookNotFound
(t *testing.T)
pkg/api/books_test.go:770
Function
TestFindBookRejectsInvalidID
(t *testing.T)
pkg/api/books_test.go:791
Function
TestFindBooks
(t *testing.T)
pkg/api/books_test.go:655
← previous
next →
101–200 of 337, ranked by callers