fix: set request id into headers instead of context directly
This commit is contained in:
@ -33,19 +33,14 @@ func RequestID() gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
var rid string
|
||||
|
||||
if rid = ctx.GetString(requestID); rid != "" {
|
||||
// request id exists already
|
||||
ctx.Next()
|
||||
}
|
||||
|
||||
if rid = ctx.GetHeader(requestID); rid != "" {
|
||||
ctx.Set(requestID, rid)
|
||||
ctx.Request.Header.Add(requestID, rid)
|
||||
ctx.Next()
|
||||
}
|
||||
|
||||
rid = uuid.NewString()
|
||||
ctx.Set(requestID, rid)
|
||||
ctx.Writer.Header().Add(requestID, rid)
|
||||
ctx.Request.Header.Add(requestID, rid)
|
||||
ctx.Header(requestID, rid)
|
||||
ctx.Next()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user