Wednesday, 7 August 2013

Jersey matches regex pattern before the method type

Jersey matches regex pattern before the method type

Is it possible to define 2 methods in Jerseywith same regex but different
type? (GET, PUT ..):
@GET
@Path("{key: [^/]+}")
@Produces(MediaType.TEXT_PLAIN)
public Response root(String Key) {
}
@PUT
@Path("{key: [^/]+}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public Response publish(String key) String repoKey, FormDataMultiPart data) {
}
The first method should only reply for the key (with or without slashes)
OK - GET /key
OK - GET /key/
OK - PUT /key
OK - PUT /key/
405 Method Not Allowed - PUT /key/folder/folder
Why the last one doesn't work? it seems Jersey first looks for regex even
though it's a PUT request.

No comments:

Post a Comment