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 <charon@lethean.io>
This commit is contained in:
parent
aa69d9c933
commit
1e5af44364
1 changed files with 3 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue