Download middleware/request-id.go from AZILS/new-api: direct link, hf CLI and curl.
- Browser
- Download file 442 Bytes
-
https://huggingface.co/spaces/AZILS/new-api/resolve/main/middleware/request-id.go
- Command line
-
hf download hf://spaces/AZILS/new-api/middleware/request-id.go
-
curl -L -o request-id.go https://huggingface.co/spaces/AZILS/new-api/resolve/main/middleware/request-id.go
442 Bytes
| package middleware | |
| import ( | |
| "context" | |
| "github.com/QuantumNous/new-api/common" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| func RequestId() func(c *gin.Context) { | |
| return func(c *gin.Context) { | |
| id := common.GetTimeString() + common.GetRandomString(8) | |
| c.Set(common.RequestIdKey, id) | |
| ctx := context.WithValue(c.Request.Context(), common.RequestIdKey, id) | |
| c.Request = c.Request.WithContext(ctx) | |
| c.Header(common.RequestIdKey, id) | |
| c.Next() | |
| } | |
| } | |