I am attempting to get a Feign client to work where the method signature of the downstream call is (@RequestBody someObject, @RequestHeaders Map<String, String> headers)
. But am unable to find any workable solution. Have tried the @HeaderMap annotation, but Feign ignores it and tells me I have too many RequestBody paramaters in the method. The @RequestHeader only allows a single, declarative, header to be set. I'm unsure a RequestInterceptor will work either because I need these headers passed from the previous request. I feel like Sleuth already does this somehow - so I think it has to be possible.
So I did not find a great solution to this, but the solution I came up with was to use a Feign RequestInterceptor
to add headers to the requests which are stored in a ThreadLocal that is set right before the FeignClient
implementation is called. Not the most elegant, and won't work if we ever move off the 1 thread per request type paradigm, but all I could think of for now.