MCPcopy Create free account

hub / github.com/Trakora/production-go-api-template / functions

Functions92 in github.com/Trakora/production-go-api-template

↓ 29 callersFunctionRespondWithError
( r *http.Request, w http.ResponseWriter, code int, msg string, err error, )
pkg/router/respond.go:20
↓ 14 callersMethodErrorf
(format string, v ...any)
pkg/logger/logger.go:46
↓ 14 callersMethodInfof
(format string, v ...any)
pkg/logger/logger.go:38
↓ 8 callersMethodHeader
()
api/router/middleware/requestlog.go:178
↓ 8 callersMethodWarnf
(format string, v ...any)
pkg/logger/logger.go:42
↓ 7 callersFunctionRespondWithJSON
( r *http.Request, w http.ResponseWriter, code int, payload any, )
pkg/router/respond.go:42
↓ 6 callersMethodrecordFailure
(ipStr string)
api/router/middleware/authentication.go:213
↓ 5 callersMethodWithRequestID
(ctx context.Context)
pkg/logger/logger.go:21
↓ 5 callersMethodWriteHeader
(statusCode int)
api/router/middleware/requestlog.go:182
↓ 5 callersFunctionserviceFromRequest
(db *gorm.DB, r *http.Request)
api/resource/item/handler.go:162
↓ 4 callersFunctionExtractAndValidateContext
(ctx context.Context, key any)
pkg/validator/context_validator.go:8
↓ 3 callersMethodValidate
()
pkg/validator/json_validator.go:9
↓ 2 callersMethodCreate
(ctx context.Context, item Item)
api/resource/item/repository.go:12
↓ 2 callersFunctionDecodeAndValidate
(r *http.Request, v T)
pkg/validator/json_validator.go:12
↓ 2 callersMethodDelete
(ctx context.Context, id int)
api/resource/item/repository.go:16
↓ 2 callersMethodWrite
(p []byte)
api/router/middleware/requestlog.go:190
↓ 2 callersFunctiongenerate_secure_string
(num_bytes: int)
generate_tokens.py:7
↓ 2 callersFunctiontruncateBody
(body []byte)
api/router/middleware/requestlog.go:89
↓ 1 callersFunctionAutoMigrateAll
(db *gorm.DB)
api/resource/migrations.go:9
↓ 1 callersFunctionCORS
(allowedOrigins []string)
api/router/middleware/cors.go:7
↓ 1 callersMethodCreateItem
(ctx context.Context, req CreateItemRequest)
api/resource/item/service.go:25
↓ 1 callersFunctionCreateItemHandler
(db *gorm.DB, w http.ResponseWriter, r *http.Request)
api/resource/item/handler.go:17
↓ 1 callersFunctionCreateStack
(xs ...Middleware)
api/router/middleware/middlewares.go:10
↓ 1 callersMethodDeleteItem
(ctx context.Context, id int)
api/resource/item/service.go:107
↓ 1 callersFunctionDeleteItemHandler
(db *gorm.DB, w http.ResponseWriter, r *http.Request)
api/resource/item/handler.go:130
↓ 1 callersMethodFatalf
(format string, v ...any)
pkg/logger/logger.go:50
↓ 1 callersMethodGetAll
(ctx context.Context)
api/resource/item/repository.go:14
↓ 1 callersMethodGetAllItems
(ctx context.Context)
api/resource/item/service.go:66
↓ 1 callersFunctionGetAllItemsHandler
(db *gorm.DB, w http.ResponseWriter, r *http.Request)
api/resource/item/handler.go:71
↓ 1 callersMethodGetByID
(ctx context.Context, id int)
api/resource/item/repository.go:13
↓ 1 callersMethodGetItem
(ctx context.Context, id int)
api/resource/item/service.go:52
↓ 1 callersFunctionGetItemHandler
(db *gorm.DB, w http.ResponseWriter, r *http.Request)
api/resource/item/handler.go:39
↓ 1 callersFunctionGetRequestID
(ctx context.Context)
pkg/contextkeys/helpers.go:7
↓ 1 callersFunctionInjectDeps
(cfg *config.Conf, log *logger.Logger)
api/router/middleware/inject_deps.go:11
↓ 1 callersMethodMiddleware
()
api/router/middleware/authentication.go:70
↓ 1 callersFunctionMount
(mux *http.ServeMux, prefix string, handler http.Handler)
pkg/router/mount.go:8
↓ 1 callersFunctionNew
()
config/config.go:52
↓ 1 callersFunctionNewAuthenticator
(authCfg config.ConfAuth, secCfg config.ConfSecurity, log *logger.Logger)
api/router/middleware/authentication.go:51
↓ 1 callersFunctionNewHealthHandler
()
api/resource/health/handler.go:15
↓ 1 callersFunctionNewItemHandler
(db *gorm.DB)
api/router/item_router.go:14
↓ 1 callersFunctionNewSQLiteItemRepo
(db *gorm.DB)
api/resource/item/repository.go:23
↓ 1 callersFunctionNewService
(cfg *config.Conf, db *gorm.DB, log *logger.Logger)
api/resource/item/service.go:17
↓ 1 callersMethodRegisterRoutes
(mux *http.ServeMux)
api/router/item_router.go:18
↓ 1 callersFunctionRequestLog
(l *logger.Logger)
api/router/middleware/requestlog.go:43
↓ 1 callersFunctionSetupItemRouter
(db *gorm.DB)
api/router/item_router.go:47
↓ 1 callersFunctionSetupRouter
(db *gorm.DB)
api/router/router.go:11
↓ 1 callersMethodUpdate
(ctx context.Context, id int, item Item)
api/resource/item/repository.go:15
↓ 1 callersMethodUpdateItem
(ctx context.Context, id int, req UpdateItemRequest)
api/resource/item/service.go:80
↓ 1 callersFunctionUpdateItemHandler
(db *gorm.DB, w http.ResponseWriter, r *http.Request)
api/resource/item/handler.go:92
↓ 1 callersMethodblockSubnet
(ipStr string)
api/router/middleware/authentication.go:246
↓ 1 callersMethodcleanupLoop
()
api/router/middleware/authentication.go:281
↓ 1 callersFunctionclientIP
(r *http.Request)
api/router/middleware/authentication.go:176
↓ 1 callersFunctionentryFields
(le *logEntry)
api/router/middleware/requestlog.go:146
↓ 1 callersMethodextractBearerToken
(w http.ResponseWriter, r *http.Request, ip string)
api/router/middleware/authentication.go:118
↓ 1 callersFunctionextractClientIP
(r *http.Request)
api/router/middleware/requestlog.go:166
↓ 1 callersFunctionfinalizeEntry
(le *logEntry, stats *responseStats)
api/router/middleware/requestlog.go:130
↓ 1 callersFunctiongenerateRequestID
()
api/router/middleware/request_id.go:32
↓ 1 callersFunctiongetRequestIDFromContext
(r *http.Request)
api/router/middleware/requestlog.go:111
↓ 1 callersFunctiongetServerIP
(r *http.Request)
api/router/middleware/requestlog.go:120
↓ 1 callersMethodgetSlowdown
(ipStr string)
api/router/middleware/authentication.go:272
↓ 1 callersMethodhandleBlockedIP
(r *http.Request, w http.ResponseWriter, ip string)
api/router/middleware/authentication.go:103
↓ 1 callersMethodhandleSignature
(w http.ResponseWriter, r *http.Request, ip, token string)
api/router/middleware/authentication.go:128
↓ 1 callersMethodhandleSlowdown
(ip string)
api/router/middleware/authentication.go:112
↓ 1 callersMethodisBlocked
(ipStr string)
api/router/middleware/authentication.go:188
↓ 1 callersFunctionmain
()
generate_tokens.py:13
↓ 1 callersFunctionmigrate
(db *gorm.DB, l *logger.Logger)
cmd/main.go:108
↓ 1 callersFunctionnewLogEntry
(r *http.Request, header map[string][]string, body string, start time.Time)
api/router/middleware/requestlog.go:96
↓ 1 callersFunctionopenDatabase
(path string, l *logger.Logger, gl gormlogger.LogLevel)
cmd/main.go:98
↓ 1 callersFunctionreadAndRestoreBody
(r *http.Request, l *logger.Logger)
api/router/middleware/requestlog.go:65
↓ 1 callersMethodresetIP
(ipStr string)
api/router/middleware/authentication.go:263
↓ 1 callersFunctionsanitizeHeaders
(header http.Header)
api/router/middleware/requestlog.go:76
↓ 1 callersFunctionvalidateHMAC
(message, signature, secret string)
api/router/middleware/authentication.go:165
MethodCheckHandler
(w http.ResponseWriter, r *http.Request)
api/resource/health/handler.go:23
FunctionContentTypeJSON
(next http.Handler)
api/router/middleware/content_type.go:13
MethodCreate
(ctx context.Context, item Item)
api/resource/item/repository.go:27
MethodCreateItemHandler
(w http.ResponseWriter, r *http.Request)
api/router/item_router.go:26
MethodDebugf
(format string, v ...any)
pkg/logger/logger.go:34
MethodDelete
(ctx context.Context, id int)
api/resource/item/repository.go:79
MethodDeleteItemHandler
(w http.ResponseWriter, r *http.Request)
api/router/item_router.go:42
MethodGetAll
(ctx context.Context)
api/resource/item/repository.go:50
MethodGetAllItemsHandler
(w http.ResponseWriter, r *http.Request)
api/router/item_router.go:30
MethodGetByID
(ctx context.Context, id int)
api/resource/item/repository.go:38
MethodGetItemHandler
(w http.ResponseWriter, r *http.Request)
api/router/item_router.go:34
FunctionHealthzHandler
(w http.ResponseWriter, r *http.Request)
api/resource/health/handler.go:19
FunctionNew
(level zerolog.Level)
pkg/logger/logger.go:15
FunctionRequestID
(next http.Handler)
api/router/middleware/request_id.go:16
MethodTracef
(format string, v ...any)
pkg/logger/logger.go:30
MethodUpdate
(ctx context.Context, id int, updatedItem Item)
api/resource/item/repository.go:59
MethodUpdateItemHandler
(w http.ResponseWriter, r *http.Request)
api/router/item_router.go:38
MethodValidate
()
api/resource/item/model.go:42
MethodValidate
()
api/resource/item/model.go:64
Functionmain
()
cmd/main.go:24