Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions docs/en/docs/tutorial/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ The middleware function receives:
* Then it returns the `response` generated by the corresponding *path operation*.
* You can then further modify the `response` before returning it.

```Python hl_lines="8-9 11 14"
{!../../docs_src/middleware/tutorial001.py!}
```
{* ../../docs_src/middleware/tutorial001.py hl[8:9,11,14] *}

/// tip

Expand All @@ -59,11 +57,10 @@ And also after the `response` is generated, before returning it.

For example, you could add a custom header `X-Process-Time` containing the time in seconds that it took to process the request and generate a response:

```Python hl_lines="10 12-13"
{!../../docs_src/middleware/tutorial001.py!}
```
{* ../../docs_src/middleware/tutorial001.py hl[10,12:13] *}

/// tip
```Python hl_lines="10 12-13"

Here we use <a href="https://docs.python.org/3/library/time.html#time.perf_counter" class="external-link" target="_blank">`time.perf_counter()`</a> instead of `time.time()` because it can be more precise for these use cases. 🤓

Expand Down