System Design
15. Software Design PatternsAnimated walkthrough
Chain of Responsibility Pattern
Pass a request along handlers until one handles it.
The idea
Each handler decides to process or forward, like middleware.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Build a chain
- 2Send the request to the first
- 3Each handles or passes on
- 4Stop when handled
1/4
Step by step
- 1Build a chain
- 2Send the request to the first
- 3Each handles or passes on
- 4Stop when handled
Where it is used
Middleware and validation.
Watch out for
Requests may fall off the end unhandled.