@@ 4,6 4,8 @@ import (
"context"
"errors"
"strings"
+
+ "github.com/labstack/echo/v4"
)
var cryptoCtxKey = &contextKey{"crypto"}
@@ 36,3 38,13 @@ func KWForContext(ctx context.Context) *KeyWallet {
}
return kw
}
+
+// Middleware adds global entropy value to the context
+func Middleware(entropy string) echo.MiddlewareFunc {
+ return func(next echo.HandlerFunc) echo.HandlerFunc {
+ return func(c echo.Context) error {
+ c.SetRequest(c.Request().WithContext(Context(c.Request().Context(), entropy)))
+ return next(c)
+ }
+ }
+}