修复feign请求头传递问题

This commit is contained in:
smallchill 2021-02-27 15:42:11 +08:00
parent 9252f24ff0
commit bb3d735c34

View File

@ -18,7 +18,9 @@ package org.springblade.core.cloud.config;
import com.alibaba.cloud.sentinel.feign.SentinelFeignAutoConfiguration;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import feign.Feign;
import feign.RequestInterceptor;
import org.springblade.core.cloud.feign.BladeFeignSentinel;
import org.springblade.core.cloud.header.BladeFeignRequestHeaderInterceptor;
import org.springblade.core.cloud.sentinel.BladeBlockExceptionHandler;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -41,8 +43,8 @@ public class BladeCloudAutoConfiguration {
@Scope("prototype")
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "feign.sentinel.enabled")
public Feign.Builder feignSentinelBuilder() {
return BladeFeignSentinel.builder();
public Feign.Builder feignSentinelBuilder(RequestInterceptor requestInterceptor) {
return BladeFeignSentinel.builder().requestInterceptor(requestInterceptor);
}
@Bean
@ -51,4 +53,10 @@ public class BladeCloudAutoConfiguration {
return new BladeBlockExceptionHandler();
}
@Bean
@ConditionalOnMissingBean
public RequestInterceptor requestInterceptor() {
return new BladeFeignRequestHeaderInterceptor();
}
}