add: LoadBalancerInterceptor

This commit is contained in:
wangiegie@gmail.com 2018-01-07 15:48:11 +08:00
parent 69da9ae0b0
commit 743d949b62
1 changed files with 8 additions and 1 deletions

View File

@ -3,11 +3,13 @@ package com.github.pig.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author lengleng
@ -37,4 +39,9 @@ public class PigGatewayApplication {
// urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
// return new CorsFilter(urlBasedCorsConfigurationSource);
// }
@Bean
LoadBalancerInterceptor loadBalancerInterceptor(LoadBalancerClient loadBalance){
return new LoadBalancerInterceptor(loadBalance);
}
}