genspark2api / middleware /request-id.go
clash-linux's picture
Upload 46 files
a48ca26 verified
raw
history blame contribute delete
419 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()
}
}