[英]How to map all http requests of the form /rest/* to @Path resource in RestEasy
我是 RestEasy 框架的新手,我正在寻找一种方法来将我的所有 http 请求与我的 @Path 注释资源 class PassThroughController 匹配。 我找不到类似的资源来帮助我。 可能是我不确定什么以及如何搜索我的要求。
这是我的应用程序 class:
@ApplicationPath("rest")
public class PassThroughService extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> clazzes = new HashSet();
clazzes.add(PassThroughController.class);
return clazzes;
}
}
直通控制器.java
@Path("/*")
public class PassThroughController
{
@GET
public Response all(@Context SecurityContext ctx) {
Response resp = Response.
ok("Welcome! "+ ctx.getUserPrincipal().getName()).
build();
return resp;
}
}
当我发送请求时: http://localhost:8080/{web-context}/rest/userservice/getuserdetails
我收到 404 错误。 但是,我希望 /rest/* 格式的任何请求都应该在我的 PassThroughController class 处被拦截。 在那里,我想要 HTTPServletRequest object 以便我可以获取路径信息、标头、参数映射和请求参数,并使用这些详细信息调用不同的服务。
所以,基本上我有两个要求:
您想使用ContainerRequestFilter
。 您不能让端点本身拦截呼叫。 有关更多详细信息,请参阅JavaDoc 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.