I am new to RestEasy framework and I am looking for a way to match all my http requests of the form /rest/* to my @Path annotated resource class PassThroughController. I could not find similar resources to help me. May be I am not sure of what and how to search for my requirement.
Here is my application class:
@ApplicationPath("rest")
public class PassThroughService extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> clazzes = new HashSet();
clazzes.add(PassThroughController.class);
return clazzes;
}
}
PassThroughController.java
@Path("/*")
public class PassThroughController
{
@GET
public Response all(@Context SecurityContext ctx) {
Response resp = Response.
ok("Welcome! "+ ctx.getUserPrincipal().getName()).
build();
return resp;
}
}
When I send a request: http://localhost:8080/{web-context}/rest/userservice/getuserdetails
I get 404 error. But, I want that any request of the format /rest/* should be intercepted at my PassThroughController class. Once there, I want HTTPServletRequest object so that I can get pathInfo, headers, parametermap and request parameters and call different services using those details.
So, basically I have two requirements:
You want to use a ContainerRequestFilter
. You can't have an endpoint itself intercept calls. See the JavaDoc for more details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.