Given the following Feign client:
@FeignClient(value="myClient", url="https://someurl", configuration=config.class)
public interface myClient {
@RequestMapping(method=Request.Method.GET, value="/somepath")
SomeResponse getSomething();
}
and this config:
@Configuration
public class config{
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("username", "password");
}
}
How could we add a header X-CorrelationToken with a value of MDC.get("token"), Specifically, we don't want to have to pass the token as a parameter to each Feign call, as we have hundreds.
I tried this:
@FeignClient(value="myClient", url="https://someurl", configuration=config.class)
@Headers("X-CorrelationToken: {MDC.get(\"token\")}")
public interface myClient {
Presumably it can be done with an interceptor, but how can I add two interceptors, given it already uses the BasicAuthRequestInterceptor?