优化feign拦截器代码
This commit is contained in:
@ -41,7 +41,7 @@ public class FeignConfig implements RequestInterceptor {
|
||||
public void apply(RequestTemplate template) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
|
||||
if (null != attributes) {
|
||||
if (Objects.nonNull(attributes)) {
|
||||
if (isNonExistsWhiteList(template.url())) {
|
||||
injectToken(template, attributes);
|
||||
}
|
||||
@ -50,6 +50,7 @@ public class FeignConfig implements RequestInterceptor {
|
||||
|
||||
// 检查请求头是否包含 currentRoleCode
|
||||
if (StringUtils.isNotEmpty(currentRoleCode)) {
|
||||
template.removeHeader(CURRENT_ROLE_CODE);
|
||||
template.header(CURRENT_ROLE_CODE, currentRoleCode);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user