閘道處理器篩選器函數
前置篩選器函數
WebMvc.fn API 具有「前置」篩選器函數的概念,即 java.util.Function<ServerRequest, ServerRequest>
,它僅作用於請求。許多前置篩選器函數在 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
在可能的情況下更受青睞。
後置篩選器函數
WebMvc.fn API 具有「後置」篩選器函數的概念,即 java.util.BiFunction<ServerRequest, ServerResponse, ServerResponse>
,它可以修改回應。許多後置篩選器函數在 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
在可能的情況下更受青睞。