MCPcopy Create free account
hub / github.com/compozy/agh / requestLoggingMiddleware

Function requestLoggingMiddleware

internal/api/httpapi/middleware.go:33–51  ·  view source on GitHub ↗
(logger *slog.Logger)

Source from the content-addressed store, hash-verified

31const maxAPIRequestBodyBytes int64 = 4 << 20
32
33func requestLoggingMiddleware(logger *slog.Logger) gin.HandlerFunc {
34 if logger == nil {
35 logger = slog.Default()
36 }
37
38 return func(c *gin.Context) {
39 started := time.Now()
40 c.Next()
41
42 logger.Info(
43 "httpapi: request",
44 "method", c.Request.Method,
45 "path", c.FullPath(),
46 "status", c.Writer.Status(),
47 "latency_ms", time.Since(started).Milliseconds(),
48 "client_ip", c.ClientIP(),
49 )
50 }
51}
52
53func corsMiddleware(boundHost string) gin.HandlerFunc {
54 return func(c *gin.Context) {

Callers 2

newTestRouterFunction · 0.85
ensureEngineMethod · 0.85

Calls 3

InfoMethod · 0.65
StatusMethod · 0.65
NowMethod · 0.45

Tested by 1

newTestRouterFunction · 0.68