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

Support having default routes without a trailing slash in annotated controllers #13

Open
fwgreen opened this issue Aug 29, 2016 · 3 comments

Comments

@fwgreen
Copy link

fwgreen commented Aug 29, 2016

If one defines a partial path on the controller, the default route ends with a trailing slash:

route("/users")
controller class UserController {

    route("") //and route("/") both map to /users/
    shared void listUsers() {}
}

This might not conform to established conventions. Might an empty route, route("") or route, be treated as the default route and separate from route("/")?

route("/users")
controller class UserController {

    route //maps to /users
    shared void listUsers() {}

    route("/") //maps to /users/
    shared void somethingElse() {}
}
@bjansen
Copy link
Owner

bjansen commented Sep 16, 2016

I can also see the opposite: https://stackoverflow.com/questions/15196698/rest-resteasy-cutting-trailing-slash-off-path
JAX-RS considers /users and /users/ to be the same routes.

I don't have a strong opinion on this topic, so if you have a real use for this feature I can implement it, it shouldn't be very hard.

@fwgreen
Copy link
Author

fwgreen commented Sep 16, 2016

I see now that I was wrong in how I stated the problem; I assumed the behavior was by design. This might actually be a bug: Going by the JAX-RS behavior, both /users and /users/ should work, but currently that is not the case:

get("/users", (req, res) => "Hello");//Going to /users/ returns a 404 error

get("/users/", (req, res) => "Hello");//Going to /users returns a 405 error

@Fleshgrinder
Copy link

I would like to second this request, my expectation would be that either "", nothing, or null allows me to access the route without a trailing slash. Stripping off the last / as JAX-RS does would be fine too since it is superfluous anyways.

@bjansen bjansen modified the milestone: 0.4 Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants