ax(mining): replace prose comments with usage examples in service.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

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 <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 16:55:07 +01:00
parent aa69d9c933
commit 1e5af44364
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -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