1、核心Prefilter
ServletDetectionFilter源码如下,还是比较简单的
public class ServletDetectionFilter extends ZuulFilter { public ServletDetectionFilter() { } public String filterType() { return "pre"; } public int filterOrder() { return -3; } public boolean shouldFilter() { return true; } public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); if (!(request instanceof HttpServletRequestWrapper) && this.isDispatcherServletRequest(request)) { ctx.set("isDispatcherServletRequest", true); } else { ctx.set("isDispatcherServletRequest", false); } return null; } private boolean isDispatcherServletRequest(HttpServletRequest request) { return request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null; } }
2、核心RoutingFilter
3、 核心PostFilter
作者:Work Hard Work Smart
出处:http://www.cnblogs.com/linlf03/
欢迎任何形式的转载,未经作者同意,请保留此段声明!