Example usage for org.springframework.boot.web.client RootUriTemplateHandler addTo

List of usage examples for org.springframework.boot.web.client RootUriTemplateHandler addTo

Introduction

In this page you can find the example usage for org.springframework.boot.web.client RootUriTemplateHandler addTo.

Prototype

public static RootUriTemplateHandler addTo(RestTemplate restTemplate, String rootUri) 

Source Link

Document

Add a RootUriTemplateHandler instance to the given RestTemplate .

Usage

From source file:org.springframework.boot.web.client.RestTemplateBuilder.java

/**
 * Configure the provided {@link RestTemplate} instance using this builder.
 * @param <T> the type of rest template
 * @param restTemplate the {@link RestTemplate} to configure
 * @return the rest template instance/*ww  w  . ja  v  a  2  s. c  om*/
 * @see RestTemplateBuilder#build()
 * @see RestTemplateBuilder#build(Class)
 */
public <T extends RestTemplate> T configure(T restTemplate) {
    configureRequestFactory(restTemplate);
    if (!CollectionUtils.isEmpty(this.messageConverters)) {
        restTemplate.setMessageConverters(new ArrayList<>(this.messageConverters));
    }
    if (this.uriTemplateHandler != null) {
        restTemplate.setUriTemplateHandler(this.uriTemplateHandler);
    }
    if (this.errorHandler != null) {
        restTemplate.setErrorHandler(this.errorHandler);
    }
    if (this.rootUri != null) {
        RootUriTemplateHandler.addTo(restTemplate, this.rootUri);
    }
    if (this.basicAuthorization != null) {
        restTemplate.getInterceptors().add(this.basicAuthorization);
    }
    if (!CollectionUtils.isEmpty(this.restTemplateCustomizers)) {
        for (RestTemplateCustomizer customizer : this.restTemplateCustomizers) {
            customizer.customize(restTemplate);
        }
    }
    restTemplate.getInterceptors().addAll(this.interceptors);
    return restTemplate;
}