blob: f9c4425b8cd50459fa080752a362949e451dc8a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package middleware
import (
"context"
"github.com/labstack/echo/v4"
)
type ContextKey string
func Context(key ContextKey, value any) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
ctx := context.WithValue(c.Request().Context(), key, value)
r := c.Request().WithContext(ctx)
c.SetRequest(r)
return next(c)
}
}
}
|