Gateway Handler Filter Functions
Before 過濾函式
WebMvc.fn API 具有“before”過濾函式(一個 java.util.Function<ServerRequest, ServerRequest>
)的概念,它只作用於請求。許多 before 過濾函式在 org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions
中作為靜態工廠方法被引用。它們在 org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions
中被適配為通用的 org.springframework.web.servlet.function.HandlerFilterFunction<ServerResponse, ServerResponse>
。兩者都可以使用,但在可能的情況下,更具體的 BeforeFilterFunctions
更受青睞,因為它更明確。
After 過濾函式
WebMvc.fn API 具有“after”過濾函式(一個 java.util.BiFunction<ServerRequest, ServerResponse, ServerResponse>
)的概念,它可以修改響應。許多 after 過濾函式在 org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions
中作為靜態工廠方法被引用。它們在 org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions
中被適配為通用的 org.springframework.web.servlet.function.HandlerFilterFunction<ServerResponse, ServerResponse>
。兩者都可以使用,但在可能的情況下,更具體的 AfterFilterFunctions
更受青睞,因為它更明確。