!51 增加feign客户端IP头部信息

Merge pull request !51 from TwelveT/N/A
pull/51/MERGE
若依 4 years ago committed by Gitee
commit 6ad1df166b

@ -2,6 +2,8 @@ package com.ruoyi.common.security.feign;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.ruoyi.common.core.utils.ip.IpUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ruoyi.common.core.constant.CacheConstants; import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.utils.ServletUtils; import com.ruoyi.common.core.utils.ServletUtils;
@ -40,6 +42,10 @@ public class FeignRequestInterceptor implements RequestInterceptor
{ {
requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication); requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication);
} }
// 配置客户端IP
requestTemplate.header("X-Forwarded-For", IpUtils.getIpAddr(ServletUtils.getRequest()));
} }
} }
} }
Loading…
Cancel
Save