diff --git a/api/src/main/java/com/teamnexters/lazy/api/config/RestTemplateConfig.java b/api/src/main/java/com/teamnexters/lazy/api/config/RestTemplateConfig.java new file mode 100644 index 0000000..9ce23d3 --- /dev/null +++ b/api/src/main/java/com/teamnexters/lazy/api/config/RestTemplateConfig.java @@ -0,0 +1,26 @@ +package com.teamnexters.lazy.api.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +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.http.converter.StringHttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +import java.nio.charset.StandardCharsets; +import java.time.Duration; + +@Configuration +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { + return restTemplateBuilder + .requestFactory(() -> new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())) + .setConnectTimeout(Duration.ofMillis(5000)) // connection-timeout + .setReadTimeout(Duration.ofMillis(5000)) // read-timeout + .additionalMessageConverters(new StringHttpMessageConverter(StandardCharsets.UTF_8)) + .build(); + } +} \ No newline at end of file