✨ Introducing new features. toc header feign 传递
This commit is contained in:
1 parent
57c1cad799
commit
ca4da3ea8b
2 files changed
+39
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
package com.pig4cloud.pigx.common.security.feign;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.WebUtils;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* TOC 客户标识传递
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2023/3/17
|
||||
*/
|
||||
@Slf4j
|
||||
public class PigxClientToCRequestInterceptor implements RequestInterceptor {
|
||||
|
||||
/**
|
||||
* Called for every request. Add data using methods on the supplied
|
||||
* {@link RequestTemplate}.
|
||||
* @param template
|
||||
*/
|
||||
public void apply(RequestTemplate template) {
|
||||
String reqVersion = WebUtils.getRequest() != null
|
||||
? WebUtils.getRequest().getHeader(SecurityConstants.HEADER_TOC) : null;
|
||||
|
||||
if (StrUtil.isNotBlank(reqVersion)) {
|
||||
log.debug("feign add header toc :{}", reqVersion);
|
||||
template.header(SecurityConstants.HEADER_TOC, reqVersion);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -32,4 +32,9 @@ public class PigxFeignClientConfiguration {
|
||||
return new PigxOAuthRequestInterceptor(tokenResolver);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestInterceptor clientToCRequestInterceptor() {
|
||||
return new PigxClientToCRequestInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user