Fegin

作者: zjkdifvpwlkqumn | 来源:发表于2020-07-20 10:40 被阅读0次

    @Configuration
    public class FeginConfiguration {
    @Bean
    public RequestInterceptor requestInterceptor() {
    return requestTemplate -> {
    String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();
    if (sessionId != null) {
    requestTemplate.header("Cookie", "SESSION=" + sessionId);
    // security添加认证
    try {
    requestTemplate.header("authorization", String.format("Basic %s",
    Base64.getEncoder().encodeToString(
    String.format("%s:%s", "user", "password").getBytes("UTF-8"))));
    } catch (UnsupportedEncodingException uee) {
    LoggerUtil.error("<fegin-service>[error]" + uee.getMessage());
    }
    }
    };
    }
    }

    相关文章

      网友评论

          本文标题:Fegin

          本文链接:https://www.haomeiwen.com/subject/axjxqktx.html