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

Index of a nested router not found #492

Closed
enners opened this issue May 11, 2020 · 3 comments
Closed

Index of a nested router not found #492

enners opened this issue May 11, 2020 · 3 comments

Comments

@enners
Copy link

enners commented May 11, 2020

When a nested router has an index, the path is ignored, leeding to a 404.

let mut router = tide::new();
router.at("/api").nest(|router| {
  router.at("/").get(async move |_| "api-root");
  router.at("/resource").get(async move |_| "resource");
});

Just adapt the nested example to review.
So, if you package a component together in a nested router, you cannot mount its root path.
PR with fix and tests is on the way though :)

enners added a commit to enners/tide that referenced this issue May 11, 2020
This was referenced May 11, 2020
@connec
Copy link

connec commented May 12, 2020

This somewhat caught me out as well. I ended up working around it by dropping the leading / from the nested routes, e.g.

let mut router = tide::new();
router.at("/api").nest(|router| {
  router.at("").get(async move |_| "api-root");
  router.at("resource").get(async move |_| "resource");
});

That definitely doesn't 'feel' very nice to me, though, and your example as written would be more natural.

@enners
Copy link
Author

enners commented May 13, 2020

@connec exactly, I work around the bug like this as well until/if my PR gets merged.

enners added a commit to enners/tide that referenced this issue May 19, 2020
enners added a commit to enners/tide that referenced this issue May 20, 2020
@enners
Copy link
Author

enners commented May 20, 2020

As mentioned in the PR, one of the recent 52 commits has fixed this one, I only left a test though.

@enners enners closed this as completed May 20, 2020
enners added a commit to enners/tide that referenced this issue Jun 3, 2020
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

2 participants