I have a Feign client that send request to given url
@FeignClient(
name = "feign-client-name",
url = "${feign.client.url}",
configuration = FeignClientConfiguration.class)
public interface SomeFeignClient {
@GetMapping(SOME_GEP_MAPPING_PATH)
Entity getEntity(String id);
}
feign:
client:
url: https://url-to-service.com
token: secret_token
internal-url: https://url-to-internal-service.com
internal: on
@RequiredArgsConstructor
public class FeignClientConfiguration {
private final FeignProperties properties;
@Bean
public RequestInterceptor requestInterceptor() {
return template -> {
template.header(HttpHeaders.AUTHORIZATION, "Token " + properties.getToken());
template.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
template.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
};
}
}
How can I change the url for feign client depends on internal property?
I want it work in following way:
if internal property has value on feign client should use internal-url value and url value in other case
UPD:
Possible solution -to use Spring Profiles.