[英]How to map all http requests of the form /rest/* to @Path resource in RestEasy
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.我是 RestEasy 框架的新手,我正在寻找一种方法来将我的所有 http 请求与我的 @Path 注释资源 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:这是我的应用程序 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直通控制器.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
当我发送请求时:
http://localhost:8080/{web-context}/rest/userservice/getuserdetails
I get 404 error.我收到 404 错误。 But, I want that any request of the format /rest/* should be intercepted at my PassThroughController class.
但是,我希望 /rest/* 格式的任何请求都应该在我的 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.
在那里,我想要 HTTPServletRequest object 以便我可以获取路径信息、标头、参数映射和请求参数,并使用这些详细信息调用不同的服务。
So, basically I have two requirements:所以,基本上我有两个要求:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.