From ea47d6dce709eb0b0c1d39a552437e4ae9129592 Mon Sep 17 00:00:00 2001 From: janeljs Date: Mon, 31 May 2021 13:14:14 +0900 Subject: [PATCH] fix: Set new http client connector (#21) --- BE/airbnb/src/main/java/airbnb/auth/AuthService.java | 6 +++++- .../java/airbnb/config/{WebConfig.java => CorsConfig.java} | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) rename BE/airbnb/src/main/java/airbnb/config/{WebConfig.java => CorsConfig.java} (73%) diff --git a/BE/airbnb/src/main/java/airbnb/auth/AuthService.java b/BE/airbnb/src/main/java/airbnb/auth/AuthService.java index 08531e15c..97f7bf78a 100644 --- a/BE/airbnb/src/main/java/airbnb/auth/AuthService.java +++ b/BE/airbnb/src/main/java/airbnb/auth/AuthService.java @@ -2,10 +2,13 @@ import airbnb.exception.AccessTokenNotFoundException; import airbnb.exception.UserNotFoundException; +import io.netty.resolver.DefaultAddressResolverGroup; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; +import reactor.netty.http.client.HttpClient; @Service public class AuthService { @@ -24,7 +27,8 @@ public class AuthService { @Value("${github.user.uri}") private String USER_URI; - private final WebClient webClient = WebClient.builder().build(); + private final HttpClient httpClient = HttpClient.create().resolver(DefaultAddressResolverGroup.INSTANCE); + private final WebClient webClient = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build(); public AccessTokenResponse getAccessTokenFrom(String code) { AccessTokenRequest accessTokenRequest = AccessTokenRequest.builder() diff --git a/BE/airbnb/src/main/java/airbnb/config/WebConfig.java b/BE/airbnb/src/main/java/airbnb/config/CorsConfig.java similarity index 73% rename from BE/airbnb/src/main/java/airbnb/config/WebConfig.java rename to BE/airbnb/src/main/java/airbnb/config/CorsConfig.java index 4ba330625..41590f86a 100644 --- a/BE/airbnb/src/main/java/airbnb/config/WebConfig.java +++ b/BE/airbnb/src/main/java/airbnb/config/CorsConfig.java @@ -1,9 +1,11 @@ package airbnb.config; +import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -public class WebConfig implements WebMvcConfigurer { +@Configuration +public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**")