适配器模式在SpringClound中的应用

请求进入网关中会碰到三类过滤器,当前路由过滤器、DefaultFilter、GpobalFilter
执行顺序:默认过滤器、路由过滤器、全局过滤器
请求路由后,会将当前路由过滤器和Defaulter、GlobalFilter合并到一个过滤器链中,排序后进行执行。

private static class GatewayFilterAdapter implements GatewayFilter {
        private final GlobalFilter delegate;

        GatewayFilterAdapter(GlobalFilter delegate) {
            this.delegate = delegate;
        }

        public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
            return this.delegate.filter(exchange, chain);
        }

        public String toString() {
            StringBuilder sb = new StringBuilder("GatewayFilterAdapter{");
            sb.append("delegate=").append(this.delegate);
            sb.append('}');
            return sb.toString();
        }
    }

你可能感兴趣的:(适配器模式)