Skip to content

Instantly share code, notes, and snippets.

@Linkit123
Last active January 9, 2022 16:33
Show Gist options
  • Save Linkit123/3cd91cca854d5232bca720aef66a27b8 to your computer and use it in GitHub Desktop.
Save Linkit123/3cd91cca854d5232bca720aef66a27b8 to your computer and use it in GitHub Desktop.
package com.dvtt.demo.coredemo.config;
import com.dvtt.demo.coredemo.interceptor.RestTemplateInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import java.util.Collections;
@Configuration
@AllArgsConstructor
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
var restTemplate = new RestTemplate();
var factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory());
restTemplate.setInterceptors(Collections.singletonList(new RestTemplateInterceptor()));
restTemplate.setRequestFactory(factory);
return restTemplate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment