I want to be able to do something like this:
@GET
@Path("test")
public Response someMethod(@Context MyCustomContext myCustomContext) {
...
}
I found this old stack overflow post that describes different methods for doing this here: Using @Context, @Provider and ContextResolver in JAX-RS. I implemented the top answer (which is implementation agnostic) and got it to work, but it didn't do exactly what I want. Instead it looked this:
@GET
@Path("test")
public Response someMethod(@Context Providers providers) {
ContextResolver<MyCustomContext> p = providers.getContextResolver(MyCustomContext.class, MediaType.WILDCARD_TYPE);
MyCustomContext myCustomContext = p.getContext(null);
...
}
There were some other solutions on that post, but they were implementation dependent. I noticed in the quarkus docs that there was a section on custom contexts that can be found here: https://quarkus.io/guides/cdi-reference#synthetic-beans, but this is specific for extensions. Does anyone have ideas on how to do this in a quarkus project?