Using Custom Middleware on a per route basis? #389
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@joa23 for router-agnostic middleware, you can use However, it looks like your middleware requires the use of the stdlib Alternatively you could write a middleware for your underlying router that only calls this middleware if the patch matches some prefix. |
Beta Was this translation helpful? Give feedback.
@joa23 for router-agnostic middleware, you can use
huma.Operation.Middlewares
when registering the operation.However, it looks like your middleware requires the use of the stdlib
http.Handler
/http.HandlerFunc
and you won't have access to the raw request/response at the Huma level. The middleware is just a few lines, so maybe you could rewrite it as a Huma middleware, see https://github.com/zitadel/zitadel-go/blob/next/pkg/http/middleware/authz.go.Alternatively you could write a middleware for your underlying router that only calls this middleware if the patch matches some prefix.