Jersey injects the request context into any argument annotated with @Context
. Is there a way I could do something similar using reflection e.g. create a Jersey Filter
/ContainerRequestFilter
or MethodInterceptor
which would allow me to inject custom parameters such as user
below into my resources?
@Path("/")
public class SomeResource {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Response postSomething(@User User user, @Context UriInfo uriInfo) {
// Do something with user
}
}
I considered using a ContainerRequestFilter
like:
@Provider
public class UserFilter implements ContainerRequestFilter {
@Context
private ResourceInfo resourceInfo;
}
But I cant see a way to get and modify the method arguments using ResourceInfo
Aucun commentaire:
Enregistrer un commentaire