-
Notifications
You must be signed in to change notification settings - Fork 405
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
Reopening #223 Which route was matched? #246
Comments
+1 for this feature. Can we attach layer to context for inspecting inside the controller? |
I think |
Same problem can occur for something like this: router.get('/users/me',...) // should match first because of order
router.get('/users/:id',...) probably relates to #231 |
+1 this is a big surprise for a routing middleware... |
I have a customized 404 controller registered at the end which cause all router.get('/some/path', controller)
router.all('*', function* (){
// behavior for not found
}) |
This is still a problem today. Tested with versions 5.4.0 and 7.4.0. Workaround:
Replace |
A simpler workaround, router holds all matches in ctx.matches array: const matchedRoute = ctx.matched.find((layer) => layer.methods.includes(ctx.method)).path; |
The PR closing #223 added
this._matchedRoute
, but there's still a bug.if you add another similar but more generic route,
this._matchedRoute
always gives the more generic route instead of the actually matched more specific oneThe text was updated successfully, but these errors were encountered: