动态设置Feign的Header信息

使用Feign的时候,有时候会动态设置headers:

//在方法参数前面添加@RequestHeader注解
@PostMapping(value = “/getStuDetail”)
public ReturnInfo getStudentDetail(@RequestBody Map map,@RequestHeader(name = “id”) String id);
//使用@RequestHeader(name = “id”)可以传递动态header属性

在idea里执行代码请求的Fiddler的拦截过滤出现:

System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyPort", "8888");
发布了144 篇原创文章 · 获赞 77 · 访问量 538万+

猜你喜欢

转载自blog.csdn.net/wtl1992/article/details/102879960