Skip to content

Commit 88d5412

Browse files
committed
doc: added mermaid graph for the request flow
1 parent d6aa7da commit 88d5412

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

docs/concepts.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@
2323
- In the `handleRequest` method, to the `Request` is attached a `Response` object (see below) that will serve the response data back to the client
2424
- When the `Response` is sent, the client is closed and freed from the memory
2525

26+
```mermaid
27+
flowchart TD
28+
A([TCP Connection]) --> B[New AsyncWebServerRequest]
29+
B --> C["Parse request line\nMETHOD · URL · GET params · HTTP/version"]
30+
C --> D[Parse headers line by line]
31+
D --> E["Apply Rewrites in order\nAll matching rewrites applied sequentially\nEach can rewrite URL and/or inject params"]
32+
E --> F["Attach Handler\nIterate handlers in order added:\nfilter() → canHandle()\nFirst match wins · fallback to catch-all"]
33+
F --> G{Body or upload?}
34+
G -- "Content-Length > 0\nor chunked transfer" --> H["Receive body / file upload\nhandleBody() · handleUpload()"]
35+
H --> I
36+
G -- no --> I([PARSE_REQ_END])
37+
38+
I --> J{mustSkipServerMiddlewares?}
39+
J -- "no (default)" --> K["Server Middlewares\nexecuted in order added\neach can call next() or short-circuit"]
40+
J -- "yes (skipServerMiddlewares)" --> L
41+
K -- "next()" --> L["Handler Middlewares\nexecuted in order added\neach can call next() or short-circuit"]
42+
K -- "short-circuit" --> N
43+
L -- "next()" --> M["handleRequest()\nattach Response object"]
44+
L -- "short-circuit" --> N
45+
M --> N["_send()\nwrite response to client asynchronously"]
46+
N --> O([Close connection · free memory])
47+
```
48+
2649
### Rewrites and how do they work
2750

2851
- The `Rewrites` are used to rewrite the request url and/or inject get parameters for a specific request url path.

mkdocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ theme:
2727
markdown_extensions:
2828
- admonition
2929
- pymdownx.details
30-
- pymdownx.superfences
30+
- pymdownx.superfences:
31+
custom_fences:
32+
- name: mermaid
33+
class: mermaid
34+
format: !!python/name:pymdownx.superfences.fence_code_format
3135
- pymdownx.highlight:
3236
anchor_linenums: true
3337
line_spans: __span

0 commit comments

Comments
 (0)