public interface WebClientProvider
WebClients using a pre-configured scheme. This class returns WebClient for a
specific endpoint and encapsulates common configuration aspects of WebClient so
that code using WebClient is not required to apply further configuration to the actual client.
Client instances are typically cached allowing reuse of pooled connections if configured on the
ClientHttpConnector.| Modifier and Type | Method and Description |
|---|---|
static WebClientProvider |
create(String scheme)
|
static WebClientProvider |
create(String scheme,
ClientHttpConnector connector)
|
WebClient |
get(InetSocketAddress endpoint)
Obtain the
WebClient configured with default HTTP headers and
Consumer error callback for a given endpoint. |
HttpHeaders |
getDefaultHeaders()
Obtain the
HttpHeaders to be used by default. |
Consumer<Throwable> |
getErrorListener()
Obtain the
error listener to be used; |
static WebClientProvider |
http()
|
WebClientProvider |
withDefaultHeaders(HttpHeaders headers)
Create a new instance of
WebClientProvider applying the given headers by default. |
WebClientProvider |
withErrorListener(Consumer<Throwable> errorListener)
Create a new instance of
WebClientProvider calling the given Consumer on error. |
static WebClientProvider http()
WebClientProvider.static WebClientProvider create(String scheme)
scheme - protocol scheme such as http or https.WebClientProvider.static WebClientProvider create(String scheme, @Nullable ClientHttpConnector connector)
scheme - protocol scheme such as http or https.connector - the HTTP connector to use. Can be null.WebClientProvider.WebClient get(InetSocketAddress endpoint)
WebClient configured with default HTTP headers and
Consumer error callback for a given endpoint.HttpHeaders getDefaultHeaders()
HttpHeaders to be used by default.HttpHeaders.EMPTY by default.Consumer<Throwable> getErrorListener()
error listener to be used;WebClientProvider withDefaultHeaders(HttpHeaders headers)
WebClientProvider applying the given headers by default.headers - must not be null.WebClientProvider.WebClientProvider withErrorListener(Consumer<Throwable> errorListener)
WebClientProvider calling the given Consumer on error.errorListener - must not be null.WebClientProvider.Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.