diff --git a/pkg/mining/service.go b/pkg/mining/service.go index 6788b6d..da3f9dd 100644 --- a/pkg/mining/service.go +++ b/pkg/mining/service.go @@ -181,7 +181,7 @@ func contentTypeValidationMiddleware() gin.HandlerFunc { } } -// requestIDMiddleware adds a unique request ID to each request for tracing +// router.Use(requestIDMiddleware()) // sets X-Request-ID on every request; uses incoming header if present, otherwise generates one func requestIDMiddleware() gin.HandlerFunc { return func(c *gin.Context) { // Use existing request ID from header if provided, otherwise generate one @@ -209,7 +209,7 @@ func generateRequestID() string { return fmt.Sprintf("%d-%s", time.Now().UnixMilli(), hex.EncodeToString(randomBytes)) } -// getRequestID extracts the request ID from gin context +// reqID := getRequestID(c) // "" if not set, otherwise the X-Request-ID value stored by requestIDMiddleware func getRequestID(c *gin.Context) string { if id, exists := c.Get("requestID"); exists { if s, ok := id.(string); ok { @@ -293,7 +293,7 @@ const ( CachePublic5Min = "public, max-age=300" ) -// cacheMiddleware adds Cache-Control headers based on the endpoint. +// router.Use(cacheMiddleware()) // sets Cache-Control: no-store on mutating routes, max-age=30 on read-only routes func cacheMiddleware() gin.HandlerFunc { return func(c *gin.Context) { // Only cache GET requests