Reputation: 14317
I am trying to implement ContainerRequestFilter
and the method filter
.
How can I extract he path params from ContainerRequest request
?
I can only see a direct method to extract the query and form parameters.
Upvotes: 5
Views: 4660
Reputation: 41
For Jersey you can get path params like this:
containerRequestContext.getUriInfo().getPathParameters()
snippet for filter:
public class JerseyRequestFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext containerRequestContext {
containerRequestContext.getUriInfo().getPathParameters();
}
Upvotes: 0
Reputation: 25236
2018 answer:
containerRequest.getUriInfo().getPathParameters()
Upvotes: 1
Reputation: 55223
ContainerRequest
doesn't seem to contain that information, but you can inject a UriInfo
into the filter and use that. See UriInfo.getPathParameters()
.
Reference: How to get the value of a PathParam outside a Resource class
Upvotes: 4