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

Trouble with matching routes #57

Open
adamgruber opened this issue Jan 3, 2019 · 2 comments
Open

Trouble with matching routes #57

adamgruber opened this issue Jan 3, 2019 · 2 comments

Comments

@adamgruber
Copy link

I've come across an issue where my requests are not getting handled as I would expect. In my code I've got something like this:

module.exports = router(
  get('/users/:id', usersHandler),
  get('/users/:id/resource', resourceHandler)
);

When I make a GET request to /users/12345/resource, the usersHandler is being called, not the resourceHandler. I believe this is happening because the request matches both paths but how can ensure that my request is handled by the correct handler?

@tim-phillips
Copy link

I can confirm this as well. As a work around, place the more complicated path above the simpler one (i.e. switch the order).

@boedy
Copy link

boedy commented Jan 14, 2020

When I switch routes, both routes get called. Applying the the change made by Roman's PR, fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants