Skip to content

Commit

Permalink
fix: Set new http client connector (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
janeljs committed May 31, 2021
1 parent f2781ea commit ea47d6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion BE/airbnb/src/main/java/airbnb/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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("/**")
Expand Down

0 comments on commit ea47d6d

Please sign in to comment.