I am following the guide of the new quarkus-resteasy-reactive-jackson
extension to use it in an existing Quarkus application deployed in production.
In the Custom headers support
section it's introduced the ClientHeadersFactory
interface to allow injecting headers in a request, but you are forced to return a sync response. One can not use Uni<MultivaluedMap<String, String>>
, which is of what is desired in my case, because I need to add a token in the header, and this token is retrieved by a request to another rest endpoint that returns a Uni<Token>
.
How can I achieve this in the new implementation? If not possible, is there a workaround?
It's not possible to use Uni<MultivaluedMap<...>>
in ClientHeadersFactory
in Quarkus 2.2.x (and older versions). We may add such a feature in the near future.
Currently, you can @HeaderParam
directly. Your code could probably look as follows:
Uni<String> token = tokenService.getToken();
token.onItem().transformToUni(tokenValue -> client.doTheCall(tokenValue));
Where the client interface would be something like:
@Path("/")
public interface MyClient {
@GET
Uni<Foo> doTheCall(@HeaderParam("token") String tokenValue);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With