修复initRequest middleware
This commit is contained in:
parent
ca0cb31235
commit
20d655973a
@ -27,11 +27,12 @@ import (
|
||||
// Date : 23:08 2022/6/25
|
||||
func InitRequest() gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
httpHandleConfig := define.GetHttpHandleConfig()
|
||||
traceID := getTraceID(ctx)
|
||||
requestID := getRequestID(ctx, traceID)
|
||||
ctx.Set(define.TraceIDField, traceID)
|
||||
ctx.Set(define.RequestIDField, requestID)
|
||||
ctx.Set(define.StartRequestTimeField, time.Now())
|
||||
ctx.Set(httpHandleConfig.TraceIDField, traceID)
|
||||
ctx.Set(httpHandleConfig.RequestIDField, requestID)
|
||||
ctx.Set(httpHandleConfig.StartRequestTimeField, time.Now())
|
||||
ctx.Next()
|
||||
}
|
||||
}
|
||||
@ -57,7 +58,7 @@ func getTraceID(ctx *gin.Context) string {
|
||||
//
|
||||
// Date : 23:12 2022/6/25
|
||||
func getRequestID(ctx *gin.Context, traceID string) string {
|
||||
requestID := ctx.GetHeader("X-Forward-Request-ID")
|
||||
requestID := ctx.GetHeader("X-Forward-Request-Id")
|
||||
if len(requestID) > 0 {
|
||||
return requestID
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user