Overview of the Interceptor (Filter) Design Pattern
The Interceptor (Filter) pattern is a structural design pattern used to dynamically add pre-processing (e.g., validation, logging) and post-processing logic to a request handling flow. It decouples cross-cutting concerns from the core business logic by intercepting requests and responses through a pluggable filter chain.
Key components include:
- Filter: Independent modules that perform specific interception tasks (e.g., authentication).
- Filter Chain: Manages the ordered execution of filters and controls the flow of the request.
- Target: The core business logic or API handler.
- Filter Manager: (Optional) Responsible for creating and assembling the filter chain.