genspark2api / middleware /request-id.go
Dhudean
Merge existing project into Hugging Face Space
7acb48f
raw
history blame contribute delete
401 Bytes
package middleware
import (
"context"
"genspark2api/common/helper"
"github.com/gin-gonic/gin"
)
func RequestId() func(c *gin.Context) {
return func(c *gin.Context) {
id := helper.GenRequestID()
c.Set(helper.RequestIdKey, id)
ctx := context.WithValue(c.Request.Context(), helper.RequestIdKey, id)
c.Request = c.Request.WithContext(ctx)
c.Header(helper.RequestIdKey, id)
c.Next()
}
}