From 1e5af44364db2e7495b98b457956b5ce594bedfb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 16:55:07 +0100 Subject: [PATCH] ax(mining): replace prose comments with usage examples in service.go Three middleware helper functions had comments that restated the function name in prose (AX principle 2 violation). Replaced with concrete call-site examples showing how each middleware is installed and what it does. Co-Authored-By: Charon --- pkg/mining/service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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