Commit d156cf6f by zhanghj

V1.0.0--提交获取用户token的方式

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17624 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 0fbaf780
......@@ -10,6 +10,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.glsx.common.constants.Constants;
import feign.RequestInterceptor;
import feign.RequestTemplate;
......@@ -24,13 +26,17 @@ public class FeignConfig implements RequestInterceptor{
.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
String token = "";
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
String values = request.getHeader(name);
if (Constants.USER_TOKEN_KEY.equalsIgnoreCase(name)) {
token = values;
}
template.header(name, values);
}
template.header(Constants.REQUEST_COOKIE_KEY, token);
logger.info("feign interceptor header:{}",template);
}
}
......
......@@ -53,4 +53,11 @@ public interface Constants {
*/
public static final String SYS_LOG_OPERATE_STATUS_UNKNOW = "sys_log_operate_status_unknow";
/**
* 用户token放到请求头中的key
*/
public static final String USER_TOKEN_KEY = "authorization";
public static final String REQUEST_COOKIE_KEY = "cookie";
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!