Download internal/api/middleware/request_id.go from shimen/API: direct link, hf CLI and curl.
- Browser
- Download file 344 Bytes
-
https://huggingface.co/spaces/shimen/API/resolve/main/internal/api/middleware/request_id.go
- Command line
-
hf download hf://spaces/shimen/API/internal/api/middleware/request_id.go
-
curl -L -o request_id.go https://huggingface.co/spaces/shimen/API/resolve/main/internal/api/middleware/request_id.go
344 Bytes
| package middleware | |
| import ( | |
| "github.com/gin-gonic/gin" | |
| "github.com/google/uuid" | |
| ) | |
| func RequestID() gin.HandlerFunc { | |
| return func(c *gin.Context) { | |
| requestID := c.GetHeader("X-Request-ID") | |
| if requestID == "" { | |
| requestID = uuid.New().String() | |
| } | |
| c.Set("request_id", requestID) | |
| c.Header("X-Request-ID", requestID) | |
| c.Next() | |
| } | |
| } | |