how to get path param von ContainerRequestContext

Ich möchte authorization-filter für meine REST-API-Endpunkt, und die filter müssen path-parameter, um die Filterung. hier ist mein Endpunkt und code:

Endpunkt:

curl --url 'localhost:80/reports/resources/org/12345/product/111 ' --request GET --header 'Authorization: <token here>'

Ressource-code:

@Path("/resources")
public class MyResource extends AbstractResource {
...
    @GET
    @Path("/org/{orgId}/product/{productId}")
    @Produces(MediaType.APPLICATION_JSON)
    @RoleAuthenticated
    public Response getResourcesReport(@PathParam("orgId") String orgId,
                                       @PathParam("productId") String productId,
                                       @Context HttpHeaders headers){....}

Filter:

@PreMatching
@RoleAuthenticated
public class AuthorizationFilter implements ContainerRequestFilter {
    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
            MultivaluedMap<String, String> pathparam = requestContext.getUriInfo().getPathParameters();   <--  return empty map  
}

Erwartete ich requestContext.getUriInfo().getPathParameters() zurückgegeben anzeigen der folgenden:

orgId 12345
productId 111

kommen, wie Sie wieder eine leere Karte ? und Wie bekomme ich den path-Parameter von ContainerRequestContext?

InformationsquelleAutor user468587 | 2016-02-05
Schreibe einen Kommentar