Skip to content
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

MIddlewares for routers #802

Closed
1 task
gulshan opened this issue Jul 3, 2024 · 1 comment
Closed
1 task

MIddlewares for routers #802

gulshan opened this issue Jul 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gulshan
Copy link

gulshan commented Jul 3, 2024

Describe the feature

Currently the middleware event handlers (with void return types) can only be attached with an App object, not a Router. Not even with a router.use('/**', middlewareEventHandler) method call. Only app.use(middlewareEventHandler, {/*specify route*/}) works. But, a lot of times, a middleware is only needed for a specific route, handled by a Router object. If middlewares were allowed to be attached to a Router, the logic would be quite straightforward.

So, my request would be, to allow middlewares to be attached with the Router objects, with a method like router.use(middlewareEventHandler).

Additional information

  • Would you be willing to help implement this feature?
@gulshan gulshan added the enhancement New feature or request label Jul 3, 2024
@gulshan
Copy link
Author

gulshan commented Aug 21, 2024

This has been taken care of in v2. Thanks @pi0
Now the hooks (like onError) are now available to H3 (previously H3App and H3Router), but only work in the global context, not when scoped to routers.

@gulshan gulshan closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant