feat: fixed lint errors

This commit is contained in:
2025-11-22 23:52:35 +03:00
parent 80ff5c501d
commit 132945342f
4 changed files with 17 additions and 8 deletions

View File

@@ -8,6 +8,11 @@ import (
"github.com/google/uuid"
)
// requestIDKey is a custom type for context key to avoid collisions
type requestIDKey struct{}
var _ requestIDKey
// RequestIDMiddleware adds a unique request ID to each request
func RequestIDMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -17,9 +22,9 @@ func RequestIDMiddleware(next http.Handler) http.Handler {
// Set request ID in response header
w.Header().Set("X-Request-ID", requestID)
// Add request ID to context
// Add request ID to context using custom type
ctx := r.Context()
ctx = context.WithValue(ctx, "request_id", requestID)
ctx = context.WithValue(ctx, requestIDKey{}, requestID)
// Log the request ID assignment
logger := logger.GetLogger()