优化feign拦截器代码

This commit is contained in:
ajaxfan
2021-04-27 15:48:18 +08:00
parent 09d783a58d
commit 0074fe5061
2 changed files with 17 additions and 17 deletions

View File

@ -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);
}
}