You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
Describe the feature
Currently the middleware event handlers (with
void
return types) can only be attached with anApp
object, not aRouter
. Not even with arouter.use('/**', middlewareEventHandler)
method call. Onlyapp.use(middlewareEventHandler, {/*specify route*/})
works. But, a lot of times, a middleware is only needed for a specific route, handled by aRouter
object. If middlewares were allowed to be attached to aRouter
, the logic would be quite straightforward.So, my request would be, to allow middlewares to be attached with the
Router
objects, with a method likerouter.use(middlewareEventHandler)
.Additional information
The text was updated successfully, but these errors were encountered: