Skip to content

Clarify difference between Target<T> and RequestInterceptor in docs regarding header injection #929

@anno1985

Description

@anno1985

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 a Target.

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIssues that require updates to our documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions