Skip to content

Commit 5c5b537

Browse files
authored
docs: update pluggable HTTP client guide to use OkHttpGitHubConnector (#2266)
Fixes #2126.
1 parent 1cd0943 commit 5c5b537

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/site/apt/index.apt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ GitHub github = GitHubBuilder.fromEnvironment().build();
139139
Pluggable HTTP client
140140

141141
This library comes with a pluggable connector to use different HTTP client implementations
142-
through <<<HttpConnector>>>. In particular, this means you can use {{{https://square.github.io/okhttp/}OkHttp}},
142+
through <<<GitHubConnector>>>. In particular, this means you can use {{{https://square.github.io/okhttp/}OkHttp}}
143+
via <<<OkHttpGitHubConnector>>> (from the <<<org.kohsuke.github.extras.okhttp3>>> package),
143144
so we can make use of its HTTP response cache.
144145
Making a conditional request against the GitHub API and receiving a 304 response
145146
{{{https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#conditional-requests}does not count against the rate limit}}.
@@ -148,7 +149,8 @@ Pluggable HTTP client
148149

149150
+-----+
150151
Cache cache = new Cache(cacheDirectory, 10 * 1024 * 1024); // 10MB cache
152+
OkHttpClient client = new OkHttpClient.Builder().cache(cache).build();
151153
GitHub gitHub = GitHubBuilder.fromEnvironment()
152-
.withConnector(new OkHttpConnector(new OkUrlFactory(new OkHttpClient().setCache(cache))))
154+
.withConnector(new OkHttpGitHubConnector(client))
153155
.build();
154156
+-----+

0 commit comments

Comments
 (0)