• Zuul核心-预定义Filter


    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 

     

  • 相关阅读:
    P1541
    P1004
    P1006
    高精度
    数组
    递归
    顺序结构
    循环结构
    变量
    分支结构
  • 原文地址:https://www.cnblogs.com/linlf03/p/12548059.html
Copyright © 2020-2023  润新知