Rest Service Client Helper
Конструктор класса
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));
}
}
Content copied to clipboard
или
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)
};
}
}
Content copied to clipboard
или (настройка для использования "proxy mode" в WireMock)
public class RestClient extends RestServiceClientHelper {
public RestClient(String host) {
super(host, b -> b.useSystemProperties();
}
}
Content copied to clipboard