Eri*_*ria 4 java resteasy quarkus
我将 Resteasy 与 Quarkus 一起使用 ( io.quarkus.quarkus-resteasy)。
我有一个在控制器上声明参数的路径。
@RequestScoped
@Path("/v1/domain/{domain}/resource")
public class MyRestController {
@POST
@Consumes(APPLICATION_JSON)
public Response create(Entity entity) {
// here I create a new entity...
}
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response get(@PathParam("id") String id) {
// get and return the entity...
}
}
Run Code Online (Sandbox Code Playgroud)
我想从该控制器外部、例如domain标有 的提供程序中或在处理传入请求的任何拦截器中检索路径参数。@Dependent
@Dependent
public class DomainProvider {
@Produces
@RequestScoped
public Domain domain() {
// retrieve the path param here !
}
}
Run Code Online (Sandbox Code Playgroud)
我没有找到一种方法来做到这一点,也没有找到相关的文档。
我都尝试过:
io.vertx.ext.web.RoutingContext和@Inject访问routingContext.pathParams()ResteasyProviderFactor恢复请求上下文数据在这两种情况下,都没有路径参数:请求路径被解析为一个简单的字符串,其中包含客户端用于联系我的 Web 服务的实际 URL。
编辑:
作为一种解决方法,在我的DomainProvider课堂上,我使用 来routingContext检索调用的 URL 和正则表达式来解析它并提取域。
| 归档时间: |
|
| 查看次数: |
3358 次 |
| 最近记录: |