h3
h3 copied to clipboard
MIddlewares for routers
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?