Commit 39474ed1 by Nepxion

简化服务和网关上下文获取Header的方式

parent f6dd9831
package com.nepxion.discovery.plugin.strategy.zuul.filter;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import org.apache.commons.lang3.StringUtils;
import com.netflix.zuul.context.RequestContext;
public class ZuulStrategyFilterResolver {
public static void setHeader(String headerName, String headerValue) {
RequestContext context = RequestContext.getCurrentContext();
// 来自于外界的Header,例如,从Postman传递过来的Header
String header = context.getRequest().getHeader(headerName);
if (StringUtils.isEmpty(header)) {
context.addZuulRequestHeader(headerName, headerValue);
}
}
}
\ No newline at end of file
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