I'm using a declarative http client of Micronaut to retrieve data from an API. But now I need to dinamically change the server address at runtime. It's possible ?
Example:
@Client("${http.client.url}")
@Header(name="Accept-Encoding", value="gzip, deflate, br")
public interface CatalogClientApi {
It's possible to change "${http.client.url}" somehow ? Or I have to switch to the low level http client?
I have then found a simple solution (a bit ugly):
@Client("/")
@Header(name="Accept-Encoding", value="gzip, deflate, br")
public interface ExampleApi {
@Post("{+path}/V1/products")
String post(@PathVariable String path, @Header("Authorization") String token, Body product);
The "@Client" has a / placeholder and then the server will be in the path variable used in {+path}. I found a bit misleading using the host here, but it's working perfectly.