Legend:

However, there's another aspect that I'd like to represent: `process_template_response` and `process_response` are applied after `process_exception`. The current docs describe `process_exception` at the end — they start with the common case; that can be confusing. They repeat that "Response middleware is always called on every response" but the concrete result is difficult to understand (at least for me) without a visual representation.

4

4

5

Finally, the schema should make clear that `process_exception` is only called in error cases, and that `process_template_response` isn't always called. Other middleware are always called (except in the case of short circuits, but as explained above, I'm leaving that outside of the scope of the schema).

6

5

7

I'm attaching (yet another) SVG file that implements these ideas and tries not to be too ugly.