Reputation: 2566
RESTEasy looks to ignore the trailing slash, so I cannot write two different web services with and without an trailing slash, and this example shows:
@Path("foo")
public class TestClass {
@GET
@Path("/bar")
public Response bar1() {
...
}
@GET
@Path("/bar/")
public Response bar2() {
...
}
}
With RESTEasy the GET-request to /foo/bar as well as /foo/bar/ are handled by bar2(). Considering RFC3986 and the JAX-RS Spec I do not see why this is handled like this. Could this be a problem with RESTEasy or is there something I oversee?
Upvotes: 4
Views: 3259
Reputation: 6660
Here is what JAX-RS specification says
3.7 Matching Requests to Resource Methods
3.7.3 Converting URI Templates to Regular Expressions
- URI encode the template, ignoring URI template variable specifications.
- Escape any regular expression characters in the URI template, again ignoring URI template variable specifications.
- Replace each URI template variable with a capturing group containing the specified regular expression or ‘([^/]+?)’ if no regular expression is specified.
- If the resulting string ends with ‘/’ then remove the final character.
- Append ‘(/.*)?’ to the result.
As I read it, the RESTEasy implements the spec correctly.
Upvotes: 4