1.Zuul四种标准过滤器类型(详细参考https://www.geekdigging.com/2019/08/31/2025584890/)
pre:执行之前
routing:执行阶段
ost:执行之后
error:发生错误时
2.创建TokenFilter类
public class TokenFilter extends ZuulFilter{
//是否需要开始过滤
@Override
public boolean shouldFilter() {
// TODO Auto-generated method stub
return true;
}
//过滤逻辑代码
@Override
public Object run() throws ZuulException {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
logger.info("--->>> TokenFilter {},{}", request.getMethod(), request.getRequestURL().toString()