feign调用在拦截器里加上cookie

  1.  
    @Configuration
  2.  
    public class TtpfFeignConfig {
  3.  
    @Bean
  4.  
    public RequestInterceptor requestInterceptor(){//Feign同步请求头
  5.  
    return template -> {
  6.  
    ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
  7.  
    if (requestAttributes != null) {
  8.  
    HttpServletRequest request = requestAttributes.getRequest();
  9.  
    template.header("Cookie",request.getHeader("Cookie"));
  10.  
    }
  11.  
    };
  12.  
    }
  13.  
    }
     
    https://blog.csdn.net/yufeiluo/article/details/141421216

 

posted @ 2024-12-17 18:45  甜菜波波  阅读(4)  评论(0编辑  收藏  举报