Closed kravorkid closed 3 months ago
hi @kravorkid did you found the solution or just a workaround to avoid the bug? do you mind if i open a pull request for this issue in the future if needed?
@sombriks the workaround i've found its to call the named routes before the route with the params, you can open a pull request for this.
I've looked deeper in the source code for what i remember it looked like both controllers we're matched and the ctx.body was filled with both properties id
and count
Hello guys, you can archive the asked behavior by marking the exclusive
option as true.
const router = new Router({ exclusive: true });
Describe the bug
Node.js version: Node v16.15.1
OS version: MacOs Ventura Version 13.3.1 (a)
Description: When multiple routes match, the router doesn't seems to execute the right controller without calling
next()
.Actual behavior
When not calling
next()
it execute the first controller and don't pass through the second, when next() is called both controllers are executedExpected behavior
Without calling
next()
it should match the right route controller and execute itEdit i've looked at the source code to see how it works under the hood i've seen the
exclusive
options that i have tested before on my use case but did not fit well with other of my controllers (that's an another story) but i have one question why execute themostSpecificLayer
should be an option ? As stated in the documentation here if we want to execute multiple middleware we just have to chain them in the route definitionCode to reproduce
Here a test i've written (for now i've found a workaround by calling my route
users/count
before the routeusers/:id
)Checklist