21 lines
426 B
Go
21 lines
426 B
Go
package middlewares
|
|
|
|
import (
|
|
"furtuna-be/internal/common/request"
|
|
"furtuna-be/internal/constants"
|
|
"furtuna-be/internal/utils/generator"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Trace() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
traceId := c.Request.Header.Get("Trace-Id")
|
|
if traceId == "" {
|
|
traceId = generator.GenerateUUID()
|
|
}
|
|
|
|
request.SetTraceId(c, traceId)
|
|
c.Set(constants.ContextRequestID, traceId)
|
|
}
|
|
}
|