()
| 9 | const RequestIdKey = "X-Any2api-Request-Id" |
| 10 | |
| 11 | func RequestId() func(c *gin.Context) { |
| 12 | return func(c *gin.Context) { |
| 13 | id := common.GetTimeString() + common.GetRandomString(8) |
| 14 | c.Set(RequestIdKey, id) |
| 15 | ctx := context.WithValue(c.Request.Context(), RequestIdKey, id) |
| 16 | c.Request = c.Request.WithContext(ctx) |
| 17 | c.Header(RequestIdKey, id) |
| 18 | c.Next() |
| 19 | } |
| 20 | } |
no test coverage detected