Add WebClient create() and build() static methods

This commit is contained in:
Sebastien Deleuze
2017-02-02 11:36:45 +01:00
parent 080a3d6a41
commit 123ee5f2da
2 changed files with 21 additions and 0 deletions

View File

@@ -48,6 +48,10 @@ class DefaultWebClientBuilder implements WebClient.Builder {
private MultiValueMap<String, String> defaultCookies;
public DefaultWebClientBuilder() {
this(new DefaultUriBuilderFactory());
}
public DefaultWebClientBuilder(String baseUrl) {
this(new DefaultUriBuilderFactory(baseUrl));
}

View File

@@ -117,6 +117,16 @@ public interface WebClient {
// Static, factory methods
/**
* Shortcut for:
* <pre class="code">
* WebClient client = builder().build();
* </pre>
*/
static WebClient create() {
return new DefaultWebClientBuilder().build();
}
/**
* Shortcut for:
* <pre class="code">
@@ -128,6 +138,13 @@ public interface WebClient {
return new DefaultWebClientBuilder(baseUrl).build();
}
/**
* Obtain a {@code WebClient} builder.
*/
static WebClient.Builder builder() {
return new DefaultWebClientBuilder();
}
/**
* Obtain a {@code WebClient} builder with a base URI to be used as the
* base for expanding URI templates during exchanges. The given String