diff options
Diffstat (limited to 'backend/api/echo_context.go')
| -rw-r--r-- | backend/api/echo_context.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/backend/api/echo_context.go b/backend/api/echo_context.go new file mode 100644 index 0000000..b775850 --- /dev/null +++ b/backend/api/echo_context.go @@ -0,0 +1,21 @@ +package api + +import ( + "context" + "errors" + + "github.com/labstack/echo/v4" +) + +type echoContextKey struct{} + +var errNoEchoContext = errors.New("echo context not found") + +func getEchoContext(ctx context.Context) echo.Context { + echoCtx, _ := ctx.Value(echoContextKey{}).(echo.Context) + return echoCtx +} + +func WithEchoContext(ctx context.Context, echoCtx echo.Context) context.Context { + return context.WithValue(ctx, echoContextKey{}, echoCtx) +} |
