RestServiceClientHelper

constructor(host: String, vararg defaultHeaders: NameValuePair)
constructor(host: String, trustAllCertificates: Boolean, vararg defaultHeaders: NameValuePair)

Конструктор класса


constructor(host: String, httpClientBuilderFunc: (HttpClientBuilder) -> HttpClientBuilder, vararg defaultHeaders: NameValuePair)

Конструктор класса.

Пример:

public class RestClient extends RestServiceClientHelper {

public RestClient(String host) {
super(host, b -> b.setUserAgent("user agent").setMaxConnTotal(10),
new BasicHeader("Content-Type", MediaType.APPLICATION_JSON));
}

}

или

public class RestClient extends RestServiceClientHelper {

public RestClient(String host) {
super(host, RestClient::executeBuilder, basicHeaders());
}

private static HttpClientBuilder executeBuilder(HttpClientBuilder builder) {
return builder.setUserAgent("user agent").setMaxConnTotal(10);
}

private static BasicHeader[] basicHeaders() {
return new BasicHeader[]{
new BasicHeader("Content-Type", MediaType.APPLICATION_JSON)
};
}

}

или (настройка для использования "proxy mode" в WireMock)

public class RestClient extends RestServiceClientHelper {

public RestClient(String host) {
super(host, b -> b.useSystemProperties();
}

}

See also