public interface HttpClient
The HTTP client context that we use to build and process requests.
HttpClient client = HttpClient.builder()
.baseUrl("http://localhost:8080")
.bodyAdapter(new JacksonBodyAdapter())
.build();
HelloDto dto = client.request()
.path("hello")
.queryParam("name", "Rob")
.queryParam("say", "Whats up")
.GET()
.bean(HelloDto.class);
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Builds the HttpClient.static interface
Components register Generated Client interface Providersstatic interface
Statistic metrics collected to provide an overview of activity of this client. -
Method Summary
Modifier and TypeMethodDescriptionReturn the BodyAdapter that this client is using.static HttpClient.Builder
builder()
Return the builder to config and build the client context.<T> T
Return the http client API implementation.metrics()
Return the current aggregate metrics.metrics
(boolean reset) Return the current metrics with the option of resetting the underlying counters.request()
Create a new request.url()
Return a UrlBuilder to use to build an URL taking into account the base URL.
-
Method Details
-
builder
Return the builder to config and build the client context.HttpClient client = HttpClient.builder() .baseUrl("http://localhost:8080") .bodyAdapter(new JacksonBodyAdapter()) .build(); HttpResponse<String> res = client.request() .path("hello") .GET().asString();
-
create
Return the http client API implementation.- Type Parameters:
T
- The service type.- Parameters:
clientInterface
- A@Client
interface with annotated API methods.- Returns:
- The http client API implementation.
-
request
HttpClientRequest request()Create a new request. -
url
UrlBuilder url()Return a UrlBuilder to use to build an URL taking into account the base URL. -
bodyAdapter
BodyAdapter bodyAdapter()Return the BodyAdapter that this client is using. -
metrics
HttpClient.Metrics metrics()Return the current aggregate metrics.These metrics are collected for all requests sent via this context.
-
metrics
Return the current metrics with the option of resetting the underlying counters.These metrics are collected for all requests sent via this context.
-