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