Spring Boot小技巧总结
Feign客户端直接指定IP调用服务
@FeignClient(value = "appblog-provider-channel-core", url="192.168.1.10:8888")
public interface ChannelPayApi extends IChannelPayApi {
}
获取请求Header
public Result<Response> query(@PathVariable("id") String id, @RequestHeader("token") String token) {
}
RequestContext请求上下文设置与获取
public class GatewayPreFilter extends ZuulFilter {
@Override
public Object run() throws ZuulException {
RequestContext.getCurrentContext().set(String key, Object value);
public class GatewayPostFilter extends ZuulFilter {
@Override
public Object run() throws ZuulException {
RequestContext requestContext = RequestContext.getCurrentContext();
Object value = (String) requestContext.get(String key);
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/25/summary-of-spring-boot-tips/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Spring Boot小技巧总结
Feign客户端直接指定IP调用服务
@FeignClient(value = "appblog-provider-channel-core", url="192.168.1.10:8888")
public interface Ch……
文章目录
关闭
共有 0 条评论