mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
✨ add NoToken Feign 注解自动维护header
This commit is contained in:
parent
1516dd709a
commit
468057ed48
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user