I'm working with Quarkus (2.0.2.Final)
This is my server side endpoint
class Endpoint {
@Path("{userId}/password")
@Consumes(MediaType.APPLICATION_JSON)
@PUT
@Transactional
public void changePassword(@QueryParam("action") String act, @PathParam("userId") long userId, AbstractPasswordResourceBean action) {...}
}
@QueryParam
"action" can be one of "reset", "reset-request", "change" and body content will vary according to action.
On client side my idea is to remap this endpoint with 3 different methods, one for any action:
@RegisterRestClient
@Path("/users")
class ClientSide {
@Path("{userId}/password?action=change")
@PUT
TokenResponse changePassword(@PathParam("userId") long userId, ChangePasswordBean request);
@Path("{userId}/password?action=reset")
@PUT
TokenResponse resetPassword(@PathParam("userId") long userId, ResetPasswordBean request);
@Path("{userId}/password?action=reset-request")
@PUT
TokenResponse requestResetPassword(@PathParam("userId") long userId, ResetPasswordRequestBean request);
}
Every call to one of above methods is resolved with a 404 because the url called is resolved as http://service:port/service-name/users/{userId}/password%3Faction=...
; the error seems to be caused by querystring encoding.
Is this a bug or a by design behaviour? Or I am missing something?
Thanks in advance for your help.
The @Path
annotation is not designed to accept a query string. Thus why it is escaped to become an acceptable path (agreed that's not what you want but that's how it works).
I don't think you'll be able to do what you want given how JAX-RS path matching works.