Add static factory methods to WebClientAdapter

Ideally one would pass WebClient directly to HttpServiceProxyFactory,
but two need to remain decoupled. This commit adds static, shortcut
methods to WebClientAdapter to create an HttpServiceProxyFactory, thus
eliminating the step to wrap the WebClient.
This commit is contained in:
rstoyanchev
2022-06-23 12:34:29 +01:00
parent 45ee7913bf
commit b72ee5f034
4 changed files with 53 additions and 14 deletions

View File

@@ -390,14 +390,10 @@ the `WebClient`:
[source,java,indent=0,subs="verbatim,quotes"]
----
WebClient client = WebClient.builder()
.baseUrl("https://api.github.com/")
.build();
WebClient client = WebClient.builder().baseUrl("https://api.github.com/").build();
HttpServiceProxyFactory factory = WebClientAdapter.createHttpServiceProxyFactory(client)).build();
HttpServiceProxyFactory proxyFactory =
HttpServiceProxyFactory.builder(new WebClientAdapter(client)).build();
RepositoryService service = proxyFactory.createClient(RepositoryService.class);
RepositoryService service = factory.createClient(RepositoryService.class);
----
An HTTP service interface can declare common attributes at the type level: