spring cloud fegin传递request header

本文链接:https://blog.csdn.net/zhongzunfa/article/details/82791903

1、概述

今天一个朋友, 遇到一个如何在使用spring cloud feign 传递token 等参数问题。

2、解决方案

2.1 创建类继承RequestInterceptor

创建类继承RequestInterceptor 具体如下代码所示:

 

2.2 在@configuration 类中定义其

 

2.3 在yml 或者properties 中添加下面关键配置

# To set thread isolation to SEMAPHORE

 

3、总结

按照上面的操作就可以将上一个服务或者是前端传递过来的header参数传递到下一个服务中去。
需要注意的是, 每个请求都会拦截设置上header信息。

4. 参考地址

http://cloud.spring.io/spring-cloud-openfeign/single/spring-cloud-openfeign.html

原文地址:https://www.cnblogs.com/lykbk/p/fhfghfghfgfh45654645654.html