]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes in `docs/en/docs/how-to/custom-request-and-route.md` (#12560)
authorPhilip Okiokio <55271518+philipokiokio@users.noreply.github.com>
Sun, 27 Oct 2024 22:12:32 +0000 (23:12 +0100)
committerGitHub <noreply@github.com>
Sun, 27 Oct 2024 22:12:32 +0000 (22:12 +0000)
docs/en/docs/how-to/custom-request-and-route.md

index a62ebf1d57067057542b5b6aa78bdb12c17e5297..f80887c0dbc344b35e1ee205675a5a7de1135304 100644 (file)
@@ -42,9 +42,8 @@ If there's no `gzip` in the header, it will not try to decompress the body.
 
 That way, the same route class can handle gzip compressed or uncompressed requests.
 
-```Python hl_lines="8-15"
-{!../../docs_src/custom_request_and_route/tutorial001.py!}
-```
+{* ../../docs_src/custom_request_and_route/tutorial001.py hl[8:15] *}
+
 
 ### Create a custom `GzipRoute` class
 
@@ -56,9 +55,9 @@ This method returns a function. And that function is what will receive a request
 
 Here we use it to create a `GzipRequest` from the original request.
 
-```Python hl_lines="18-26"
-{!../../docs_src/custom_request_and_route/tutorial001.py!}
-```
+
+{* ../../docs_src/custom_request_and_route/tutorial001.py hl[18:26] *}
+
 
 /// note | "Technical Details"
 
@@ -96,26 +95,25 @@ We can also use this same approach to access the request body in an exception ha
 
 All we need to do is handle the request inside a `try`/`except` block:
 
-```Python hl_lines="13  15"
-{!../../docs_src/custom_request_and_route/tutorial002.py!}
-```
+
+{* ../../docs_src/custom_request_and_route/tutorial002.py hl[13,15] *}
+
 
 If an exception occurs, the`Request` instance will still be in scope, so we can read and make use of the request body when handling the error:
 
-```Python hl_lines="16-18"
-{!../../docs_src/custom_request_and_route/tutorial002.py!}
-```
+
+{* ../../docs_src/custom_request_and_route/tutorial002.py hl[16:18] *}
+
+
 
 ## Custom `APIRoute` class in a router
 
 You can also set the `route_class` parameter of an `APIRouter`:
 
-```Python hl_lines="26"
-{!../../docs_src/custom_request_and_route/tutorial003.py!}
-```
+{* ../../docs_src/custom_request_and_route/tutorial003.py hl[26] *}
+
 
 In this example, the *path operations* under the `router` will use the custom `TimedRoute` class, and will have an extra `X-Response-Time` header in the response with the time it took to generate the response:
 
-```Python hl_lines="13-20"
-{!../../docs_src/custom_request_and_route/tutorial003.py!}
-```
+
+{* ../../docs_src/custom_request_and_route/tutorial003.py hl[13:20] *}