-
Notifications
You must be signed in to change notification settings - Fork 256
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
Add mounted router /
route to mounted location if no definition exists
#465
Comments
Are trailing slashes required when visiting regular endpoints? |
No, you're right, it's mostly It would be nice to have |
I'm in the camp that trailing slashes matter and should be treated as separate routes as they are separate routes. I also understand the ease of use and common pattern of defining the route once and having it work in both places. I don't think I can enable it by default at this point, but adding a method (or init flag) would work well and tell of route mismatches. |
Closing in favor of #100 |
I agree with you, the routes are different and should be treated differently. However, my point is different from issue #100 and I disagree with the renaming of this thread to "Trailing slashes should route to the same place". My core issue is that when you mount an endpoint on I maintain a relatively complex API whose main components are broken down in several plumber files and mounted (to e.g. People who integrate with our API ask me why they must put a trailing slash to As far as the end-user is concerned, it seems like some random endpoints take a trailing slash while most others do not. Feels like a leaky abstraction? |
Are you wanting the example above to work like the lists below?
And if
The way it currently implemented, you are allowed to have a custom route at So, would it be good to add the
|
Exactly! Sorry I wasn't clear in my initial post, I tried to make it generic but just confounded the issues. |
/
route to mounted location if no definition exists
Notes: Should be done at the same time as trailing slashes |
This could be accomplished if there was a way to opt-in to redirects on mounted routers: options(plumber.mount.redirect = TRUE) or pr_mount(..., redirect = TRUE) Example redirect: pr_get("/foo", function(res) {
res$status <- 307
res$setHeader(name = "Location",
value = "/foo/")
res
}) |
A trailing slash breaks the endpoint path but is required when accessing a mounted endpoint. This can make the API inconsistent.
Consider:
Running the API:
url/root
worksurl/root/
gives a 404url/sub
gives a 404url/sub/
worksIs there a way to make
/sub
be equivalent to/sub/
and/root/
to/root
? Or is it a bad idea?The text was updated successfully, but these errors were encountered: