add NoToken Feign 注解自动维护header

This commit is contained in:
冷冷 2024-07-22 11:00:47 +08:00
parent 1516dd709a
commit 468057ed48

View File

@ -20,6 +20,7 @@ import com.alibaba.cloud.sentinel.feign.SentinelFeignAutoConfiguration;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pig4cloud.pig.common.feign.core.PigFeignInnerRequestInterceptor;
import com.pig4cloud.pig.common.feign.core.PigFeignRequestCloseInterceptor;
import com.pig4cloud.pig.common.feign.sentinel.ext.PigSentinelFeign;
import com.pig4cloud.pig.common.feign.sentinel.handle.PigUrlBlockHandler;
@ -46,33 +47,43 @@ import org.springframework.context.annotation.Scope;
@AutoConfigureBefore(SentinelFeignAutoConfiguration.class)
public class PigFeignAutoConfiguration {
@Bean
@Scope("prototype")
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "feign.sentinel.enabled")
public Feign.Builder feignSentinelBuilder() {
return PigSentinelFeign.builder();
}
@Bean
@Scope("prototype")
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "feign.sentinel.enabled")
public Feign.Builder feignSentinelBuilder() {
return PigSentinelFeign.builder();
}
@Bean
@ConditionalOnMissingBean
public BlockExceptionHandler blockExceptionHandler(ObjectMapper objectMapper) {
return new PigUrlBlockHandler(objectMapper);
}
@Bean
@ConditionalOnMissingBean
public BlockExceptionHandler blockExceptionHandler(ObjectMapper objectMapper) {
return new PigUrlBlockHandler(objectMapper);
}
@Bean
@ConditionalOnMissingBean
public RequestOriginParser requestOriginParser() {
return new PigHeaderRequestOriginParser();
}
@Bean
@ConditionalOnMissingBean
public RequestOriginParser requestOriginParser() {
return new PigHeaderRequestOriginParser();
}
/**
* set connection close header
* @return RequestInterceptor
*/
@Bean
public RequestInterceptor pigFeignRequestCloseInterceptor() {
return new PigFeignRequestCloseInterceptor();
}
/**
* set connection close header
*
* @return RequestInterceptor
*/
@Bean
public RequestInterceptor pigFeignRequestCloseInterceptor() {
return new PigFeignRequestCloseInterceptor();
}
/**
* pig feign 内部请求拦截器
*
* @return {@link RequestInterceptor }
*/
@Bean
public RequestInterceptor pigFeignInnerRequestInterceptor() {
return new PigFeignInnerRequestInterceptor();
}
}