Skip to content

add RequestInterceptor - #49

Merged
codefromthecrypt merged 1 commit into
masterfrom
request-interceptor
Aug 18, 2013
Merged

codefromthecrypt merged 1 commit into
masterfrom
request-interceptor

Conversation

@codefromthecrypt

Copy link
Copy Markdown

When you need to change all requests, regardless of their target, you'll want to configure a RequestInterceptor.
For example, if you are acting as an intermediary, you might want to propagate the X-Forwarded-For header.

@Module(library = true)
static class ForwardedForInterceptor implements RequestInterceptor {
  @Provides(type = SET) RequestInterceptor provideThis() {
    return this;
  }

  @Override public void apply(RequestTemplate template) {
    template.header("X-Forwarded-For", "origin.host.com");
  }
}
...
GitHub github = Feign.create(GitHub.class, "https://api.github.com", new GsonModule(), new ForwardedForInterceptor());

@codefromthecrypt

Copy link
Copy Markdown
Author

cc @benjchristensen @syed-haq @digitalsanctum

@cloudbees-pull-request-builder

Copy link
Copy Markdown

feign-pull-requests #62 SUCCESS
This pull request looks good

codefromthecrypt pushed a commit that referenced this pull request Aug 18, 2013
@codefromthecrypt
codefromthecrypt merged commit d6fa731 into master Aug 18, 2013
@codefromthecrypt
codefromthecrypt deleted the request-interceptor branch August 18, 2013 17:49
velo pushed a commit that referenced this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants