Pre/Post Processing with Filters
Apply filters for actions before (pre) a request reaches the service and after (post) the service responds.
Intro to Pre/Post Filters
Welcome! In this lesson, we'll explore how Spring Cloud Gateway filters can process requests before they reach a backend service (pre-processing) and after the service responds (post-processing).
This fine-grained control is crucial for handling complex API gateway tasks.
The Filter Chain Revisited
Recall that filters operate in a chain. Each GatewayFilter or GlobalFilter can perform actions:
- Before calling
chain.filter(exchange): This is pre-processing. - After
chain.filter(exchange)returns aMono<Void>: This is post-processing.
The reactive nature of Spring Cloud Gateway, using Mono, makes this sequential execution powerful.
All lessons in this course
- Global Filters & GatewayFilterFactory
- Custom Request/Response Filters
- Pre/Post Processing with Filters
- Built-in GatewayFilters You Should Know