Reputation: 3172
I'm using Resteasy with Quarkus (io.quarkus.quarkus-resteasy
).
I have a path with params declared on a controller.
@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...
}
}
I would like to retrieve the domain
path param from outside this controller, in a provider marked with @Dependent
for example, or in any interceptor that process the incoming request.
@Dependent
public class DomainProvider {
@Produces
@RequestScoped
public Domain domain() {
// retrieve the path param here !
}
}
I didn't find a way to do that, nor documentation about this.
I tried both:
io.vertx.ext.web.RoutingContext
with @Inject
and access routingContext.pathParams()
ResteasyProviderFactor
to recover the request context dataIn both case, there is no path parameter : the request path is resolved as a simple string, containing the actual URL the client used to contact my web service.
Edit:
As a workaround, in my DomainProvider
class, I used the routingContext
to retrieve the called URL and a regular expression to parse it and extract the domain.
Upvotes: 4
Views: 4320
Reputation: 63991
There is no standard way to do this.
You need to pass the param from the JAX-RS resource on down to whatever piece of code needs it
Upvotes: 5