工作原理
以下圖示概覽了 Spring Cloud Gateway 的工作原理

在 Spring Cloud Gateway Server MVC 中,路由是普通的 WebMvc.fn RouterFunction
例項,它們使用在 org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions 中定義的特殊 HandlerFunction 來轉發 HTTP 請求。請參閱 WebMvc.fn 文件以瞭解函式式 API 的常規用法。
除了用於 HTTP 轉發的自定義 `HandlerFunctions` 外,Spring Cloud Gateway Server MVC 還在 org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates 中提供了額外的 `RequestPredicate` 實現,並在 org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions 中提供了 `HandlerFilterFunctions` 實現。所有純粹的“前置”自定義過濾器都在 org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions 中實現,並在 `FilterFunctions` 中作為請求處理器進行適配。在 org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions 中的自定義“後置”過濾器也在 `FilterFunctions` 中作為響應處理器進行適配。
還有額外的 `*FilterFunctions` 類用於可選過濾器,這些將在每個過濾器的文件中說明。
路由 URI 上定義的任何路徑都將被忽略。 |