gyokuro
gyokuro copied to clipboard
Support having default routes without a trailing slash in annotated controllers
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() {}
}
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.
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
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.