2021-12-21 18:46:54 +05:30
|
|
|
package middlewares
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2022-01-17 11:32:13 +05:30
|
|
|
// GinContextToContextMiddleware is a middleware to add gin context in context
|
2021-12-21 18:46:54 +05:30
|
|
|
func GinContextToContextMiddleware() gin.HandlerFunc {
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
ctx := context.WithValue(c.Request.Context(), "GinContextKey", c)
|
|
|
|
c.Request = c.Request.WithContext(ctx)
|
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|