Class RestClient

java.lang.Object
org.apache.juneau.rest.client.RestClient
All Implemented Interfaces:
Closeable, AutoCloseable

public final class RestClient extends Object implements Closeable
Next-generation transport-agnostic REST client.

Create instances via create() or builder():

// Minimal — uses the built-in JDK HttpClient transport RestClient client = RestClient.create(); // Explicit transport (e.g. for tests) RestClient client = RestClient.builder() .transport(mockTransport) .header("Accept", "application/json") .build();

By default, RestClient uses JavaHttpTransport (backed by the JDK's HttpClient), which ships built into the juneau-rest-client artifact and requires no extra dependencies on Java 11+. Pulling in one of the optional transport modules (juneau-rest-client-apache-httpclient-45, -apache-httpclient-50, -okhttp, -jetty) registers a higher-priority provider via ServiceLoader that takes over automatically. An explicit RestClient.Builder.transport(HttpTransport) call always wins.

See Also:
Since:
9.2.1