Reputation: 69
I have a microprofile that posts a request to an external service
@ApplicationScoped
@RegisterRestClient(configKey = "a")
@RegisterProvider(FilterMe.class)
public interface Client {
@POST
@Path("/send.html")
@Consumes({MediaType.APPLICATION_FORM_URLENCODED})
@Produces({MediaType.TEXT_HTML})
Response sendText(@FormParam("a") String a);
}
I am trying to filter this POST method to get the request and the response, i dont know whats the correct way I can be able to get the FormParam and the response(when i debug, i can clearly see the request in an entity InputStream object but I dont know how to get it):
public class FilterMe implements ClientRequestFilter, ClientResponseFilter {
@Context
private ResourceInfo resourceInfo;
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
}
@Override
public void filter(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) throws IOException {
}
}
Upvotes: 1
Views: 1296
Reputation: 1163
If you use the type javax.ws.rs.core.Form
as a parameter in your REST Client, you should be able to access it by calling javax.ws.rs.client.ClientRequestContext#getEntity
.
Then on the javax.ws.rs.core.Form` you are free to retrieve any parameter sent in the form.
Upvotes: 1