Include the request ID in the request logs
This commit is contained in:
@@ -152,8 +152,9 @@ func (re *RequestError) asFilesystemError() (int, string) {
|
||||
func AttachRequestID() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
id := uuid.New().String()
|
||||
c.Header("X-Request-Id", id)
|
||||
c.Set("request_id", id)
|
||||
c.Set("logger", log.WithField("request_id", id))
|
||||
c.Header("X-Request-Id", id)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
@@ -311,4 +312,4 @@ func ExtractServer(c *gin.Context) *server.Server {
|
||||
panic("middleware/middleware: cannot extract server: not present in request context")
|
||||
}
|
||||
return v.(*server.Server)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user