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
更受青睐,因为它更明确。