-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I've had a look at the docs to figure out how to inject a header for my requests, and they mention Target<T>
and RequestInterceptor
. The respective section opens:
In cases where headers should differ for the same api based on different endpoints or where per-request customization is required, headers can be set as part of the client using a
RequestInterceptor
or aTarget
.
The docs also state:
When you need to change all requests, regardless of their target, you'll want to configure a RequestInterceptor
So, if I want to set header A
to foo
for target 1
, and to bar
for target 2
, I use Target<T>
, otherwise (if I want to set the same value for the same header for all requests and targets) RequestInterceptor
.
What I find confusing is that the target(...)
method is the terminator for the Feign Builder
. So I can't specify two different targets on the same builder (unless I assign a builder to variable before calling target(...)
, but I don't think I have seen that done anywhere in the docs), and the RequestInterceptor
is set on the Builder
, too - which leads me to ask, where is the difference, really?
Isn't the request interceptor in pretty much all cases going to be per target as well?