What I'm currently doing (which is very simple and convenient way):
Feign.builder()
.client(RibbonClient.create())
...
.requestInterceptor(new MyInterceptor())
But interception occur before ribbon actually resolve target host. Problem is, that one header that I want to add, have to be created based on the name of the target host.
Is there anyway I can manipulate headers after host is resolved?
I have found following solution for this problem. Instead of using Feign interceptor I use RibbonClient delegate:
MyDelegate
extendsfeign.Client.Default
class and overridespublic Response execute(Request request, Request.Options options)
method.In this way I can access target host by
URI.create(request.url()).getHost()
.Then I create new Request, add my header and run
super.execute(newRequest, options)
as the last instruction.