-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we accept middleware in @hono/zod-openapi
's openapi method?
#159
Comments
Because of the presence of hook after handler, |
Hi @naporin0624 Thank you for using it.
Yes. Of course, I'd like to support various patterns, but it's too difficult to keep type infering correct. To make it come true, I think we have to write type definitions like complex this: https://github.com/honojs/hono/blob/main/src/types.ts#L70 For this middleware, we/I want to the type definition keep simple. |
Sorry, I'm not sure what to do. It took me a very long time to reply. I looked at Is this a recommended way to apply middleware to a specific path while using the app.on([route.method], route.path.replaceAll(/\/{(. +?)} /g, '/:$1'), . .middleware)
app.openapi(route, handler) I will also try to operate a compose function that combines the middleware and handler into one by applying a HandlerInterface-like type there. Thank you very much. |
How about adding a method like app.use(route.getRoutingPath(), mw) // if `path` is `/users/{id}`, it will be `app.use('/users/:id', mw)`
app.openapi(route, handler) |
It's a very simple and good idea! |
Thank you for creating a very usable library.
I am now using @hono/zod-openapi for my project.
It is possible to insert middleware as follows
Is it possible to change the interface to accept middleware as handler, like
Hono.get
orHono.post
? I'd like to create a PR, but I'm wondering if there are any barriers that have prevented me from doing so in the past?The text was updated successfully, but these errors were encountered: