Description
middleware/logger.go:33 does:
reqID, _ := c.Get(CtxRequestID)
logger.L.Info("request", zap.String("request_id", reqID.(string)), ...)
If CtxRequestID is not set in the context for any reason, reqID is nil and reqID.(string) panics. gin.Recovery() would catch it, but only after the response is already broken.
Location
middleware/logger.go:33
Fix
Use c.GetString(CtxRequestID) which returns an empty string safely instead of the bare type assertion.
Description
middleware/logger.go:33does:If
CtxRequestIDis not set in the context for any reason,reqIDisnilandreqID.(string)panics.gin.Recovery()would catch it, but only after the response is already broken.Location
middleware/logger.go:33Fix
Use
c.GetString(CtxRequestID)which returns an empty string safely instead of the bare type assertion.