I have a JAX-RS rest client with following definition.
@PUT
@Path("/payments/{paymentId}/operation")
void call(@PathParam("paymentId") String paymentId, Object request);
I would like to intercept this outgoing request and read the paymentId
value in a ClientRequestFilter
.
@Provider
public class TracingInterceptor implements ClientRequestFilter {
public static final String PAYMENT_ID = "paymentId";
@Context
UriInfo info;
@Override
public void filter(ClientRequestContext requestContext) {
// read paymentId
}
}
I tried with UriInfo
which works for ContainerRequestFilter
but the context is not available in a ClientRequestFilter
.
How can I read a specific path parameter in a ClientRequestFilter
?
Use
ClientRequestContext#getUri
: https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/ClientRequestContext.html#getUri.