Adds a decorator for Okhttp requests by hgschmie · Pull Request #1013 · scribejava/scribejava · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class OkHttpHttpClientConfig implements HttpClientConfig {

private final OkHttpClient.Builder clientBuilder;
private OkHttpRequestDecorator decorator;

public OkHttpHttpClientConfig(OkHttpClient.Builder clientBuilder) {
this.clientBuilder = clientBuilder;
Expand All @@ -23,4 +24,19 @@ public OkHttpHttpClientConfig createDefaultConfig() {
public static OkHttpHttpClientConfig defaultConfig() {
return new OkHttpHttpClientConfig(null);
}

public OkHttpRequestDecorator getDecorator() {
return decorator;
}

public void setDecorator(OkHttpRequestDecorator decorator) {
this.decorator = decorator;
}

public OkHttpHttpClientConfig withDecorator(OkHttpRequestDecorator decorator) {
this.decorator = decorator;
return this;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.scribejava.httpclient.okhttp;

import okhttp3.Request;

/**
* Allows interception of the request building process, e.g. to add custom headers or tags.
*/
public interface OkHttpRequestDecorator {

void decorate(Request.Builder requestBuilder);
}