Journeycorner
Journeycorner

Reputation: 2542

Obtaining a Micronaut HttpClient with url from property

I want to obtain the HttpClient by the Client annotation, so it is managed by Micronaut. However this way I can't use a url from my property file:

public FooService(
   @Value("${url}") String url,
   // I can't use url here, but @Client needs an non empty url parameter
   @Client(url) RxHttpClient httpClient
   // other constructor arguments...
)

Is there to let Micronaut manage the HttpClient while still using a url from my application.yml?

Upvotes: 0

Views: 1439

Answers (1)

Georg Moser
Georg Moser

Reputation: 706

You could inject the url from your properties using:

@Client("${myproperties.url}")
RxWebSocketClient webSocketClient;

See: https://docs.micronaut.io/latest/guide/httpClient.html

Upvotes: 1

Related Questions