-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
api/src/main/java/com/teamnexters/lazy/api/config/RestTemplateConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |