Commit 34f571e8 by Nepxion

修复Feign上下文的Bug

parent 52c1a804
......@@ -37,9 +37,17 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes == null) {
return;
}
HttpServletRequest request = attributes.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
if (headerNames != null) {
if (headerNames == null) {
return;
}
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String header = request.getHeader(headerName);
......@@ -49,5 +57,4 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
}
}
}
}
}
\ No newline at end of file
......@@ -65,6 +65,10 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
private boolean applyFromHeader(Server server, Map<String, String> metadata) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes == null) {
return true;
}
String token = attributes.getRequest().getHeader("token");
// String value = attributes.getRequest().getParameter("value");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment