Using Custom Middleware on a per route basis? #389
-
|
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
@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 I was looking at the same tool and made a basic middleware. You just pass the authorizer provided from zitadel and the options like normal |
Beta Was this translation helpful? Give feedback.
@joa23 for router-agnostic middleware, you can use
huma.Operation.Middlewareswhen registering the operation.However, it looks like your middleware requires the use of the stdlib
http.Handler/http.HandlerFuncand 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.