Example usage for org.springframework.http.client.support InterceptingHttpAccessor setInterceptors

List of usage examples for org.springframework.http.client.support InterceptingHttpAccessor setInterceptors

Introduction

In this page you can find the example usage for org.springframework.http.client.support InterceptingHttpAccessor setInterceptors.

Prototype

public void setInterceptors(List<ClientHttpRequestInterceptor> interceptors) 

Source Link

Document

Set the request interceptors that this accessor should use.

Usage

From source file:io.jmnarloch.spring.request.correlation.http.ClientHttpCorrelationConfiguration.java

@Bean
public InitializingBean clientsCorrelationInitializer(final RequestCorrelationProperties properties) {

    return new InitializingBean() {
        @Override// w ww  .  ja va  2 s .  c o m
        public void afterPropertiesSet() throws Exception {

            if (clients != null) {
                for (InterceptingHttpAccessor client : clients) {
                    final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(
                            client.getInterceptors());
                    interceptors.add(new ClientHttpRequestCorrelationInterceptor(properties));
                    client.setInterceptors(interceptors);
                }
            }
        }
    };
}