P0 fixes: - ModelError.Is(): use exact matching instead of substring contains() - shouldClearStickySession: add context param for cancellation/tracing P1 fixes: - TODO stubs: return 501 Not Implemented errors - validateInstanceSignature: deduplicate to shared validateCodeSignature() - Error messages: standardize to English only - http.go: remove pseudo if-else with duplicate branches
20 lines
457 B
Go
20 lines
457 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/Wei-Shaw/sub2api/internal/pkg/logger"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func requestLogger(c *gin.Context, component string, fields ...zap.Field) *zap.Logger {
|
|
base := logger.L()
|
|
if c != nil && c.Request != nil {
|
|
base = logger.FromContext(c.Request.Context())
|
|
}
|
|
|
|
if component != "" {
|
|
fields = append([]zap.Field{zap.String("component", component)}, fields...)
|
|
}
|
|
return base.With(fields...)
|
|
}
|