spring gateway 学习记录

spring gateway 4.2.0 关键步骤记录

spring gateway自定义filter和predicate组件都需要按照指定格式命名:xxxGatewayFilterFactoryxxxRoutePredicateFactory,"xxx"用来作为key匹配指定的filter和predicate。

启动两个核心类

  • RouteDefinitionRouteLocator:获取容器中GatewayFilterFactory、RoutePredicateFactory、GatewayProperties中配置的routes。解析前两个工厂用于匹配GatewayProperties中的predicates属性
  • CachingRouteLocator:获取容器中的DSL格式(@Bean格式)的RouteLocator以及上面的RouteDefinitionRouteLocator生成组合代理类

(两个核心类)

RouteDefinitionRouteLocator

获取GatewayFilterFacotry、RoutePredicateFactory、GatewayProperties后,对工厂类进行处理(截取工厂名称)

获取GatewayFilterFacotry、RoutePredicateFactory、GatewayProperties

谓词工厂与配置文件映射,以AfterRoutePredicateFactory为例

工厂与配置文件的映射处理

posted on 2025-02-19 15:47  树下的  阅读(46)  评论(0)    收藏  举报