- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 28 for APIRoute (0.74 sec)
-
docs/de/docs/how-to/custom-request-and-route.md
# Benutzerdefinierte Request- und APIRoute-Klasse In einigen Fällen möchten Sie möglicherweise die von den Klassen `Request` und `APIRoute` verwendete Logik überschreiben. Das kann insbesondere eine gute Alternative zur Logik in einer Middleware sein. Wenn Sie beispielsweise den Requestbody lesen oder manipulieren möchten, bevor er von Ihrer Anwendung verarbeitet wird. !!! danger "Gefahr" Dies ist eine „fortgeschrittene“ Funktion.
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Sat Mar 30 18:18:23 UTC 2024 - 5.2K bytes - Viewed (0) -
tests/test_route_scope.py
import pytest from fastapi import FastAPI, Request, WebSocket, WebSocketDisconnect from fastapi.routing import APIRoute, APIWebSocketRoute from fastapi.testclient import TestClient app = FastAPI() @app.get("/users/{user_id}") async def get_user(user_id: str, request: Request): route: APIRoute = request.scope["route"] return {"user_id": user_id, "path": route.path} @app.websocket("/items/{item_id}")
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Wed Feb 08 10:23:07 UTC 2023 - 1.5K bytes - Viewed (0) -
docs_src/generate_clients/tutorial003.py
from typing import List from fastapi import FastAPI from fastapi.routing import APIRoute from pydantic import BaseModel def custom_generate_unique_id(route: APIRoute): return f"{route.tags[0]}-{route.name}" app = FastAPI(generate_unique_id_function=custom_generate_unique_id) class Item(BaseModel): name: str price: float class ResponseMessage(BaseModel): message: str
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Mar 04 22:02:18 UTC 2022 - 939 bytes - Viewed (0) -
tests/test_custom_route_class.py
import pytest from fastapi import APIRouter, FastAPI from fastapi.routing import APIRoute from fastapi.testclient import TestClient from starlette.routing import Route app = FastAPI() class APIRouteA(APIRoute): x_type = "A" class APIRouteB(APIRoute): x_type = "B" class APIRouteC(APIRoute): x_type = "C" router_a = APIRouter(route_class=APIRouteA) router_b = APIRouter(route_class=APIRouteB)
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 3.1K bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial003.py
import time from typing import Callable from fastapi import APIRouter, FastAPI, Request, Response from fastapi.routing import APIRoute class TimedRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: before = time.time() response: Response = await original_route_handler(request)
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 1K bytes - Viewed (0) -
docs/em/docs/how-to/custom-request-and-route.md
# 🛃 📨 & APIRoute 🎓 💼, 👆 5️⃣📆 💚 🔐 ⚛ ⚙️ `Request` & `APIRoute` 🎓. 🎯, 👉 5️⃣📆 👍 🎛 ⚛ 🛠️. 🖼, 🚥 👆 💚 ✍ ⚖️ 🔬 📨 💪 ⏭ ⚫️ 🛠️ 👆 🈸. !!! danger 👉 "🏧" ⚒. 🚥 👆 ▶️ ⏮️ **FastAPI** 👆 💪 💚 🚶 👉 📄. ## ⚙️ 💼 ⚙️ 💼 🔌: * 🏭 🚫-🎻 📨 💪 🎻 (✅ <a href="https://msgpack.org/index.html" class="external-link" target="_blank">`msgpack`</a>). * 🗜 🗜-🗜 📨 💪. * 🔁 🚨 🌐 📨 💪.
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 3.6K bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial002.py
from typing import Callable, List from fastapi import Body, FastAPI, HTTPException, Request, Response from fastapi.exceptions import RequestValidationError from fastapi.routing import APIRoute class ValidationErrorLoggingRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: try:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 932 bytes - Viewed (0) -
docs/en/docs/how-to/custom-request-and-route.md
# Custom Request and APIRoute class In some cases, you may want to override the logic used by the `Request` and `APIRoute` classes. In particular, this may be a good alternative to logic in a middleware. For example, if you want to read or manipulate the request body before it is processed by your application. !!! danger This is an "advanced" feature. If you are just starting with **FastAPI** you might want to skip this section.
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Sun Mar 31 23:52:53 UTC 2024 - 4.4K bytes - Viewed (0) -
docs_src/path_operation_advanced_configuration/tutorial002.py
from fastapi import FastAPI from fastapi.routing import APIRoute app = FastAPI() @app.get("/items/") async def read_items(): return [{"item_id": "Foo"}] def use_route_names_as_operation_ids(app: FastAPI) -> None: """ Simplify operation IDs so that generated API clients have simpler function names. Should be called only after all routes have been added. """ for route in app.routes:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 572 bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial001.py
from fastapi.routing import APIRoute class GzipRequest(Request): async def body(self) -> bytes: if not hasattr(self, "_body"): body = await super().body() if "gzip" in self.headers.getlist("Content-Encoding"): body = gzip.decompress(body) self._body = body return self._body class GzipRoute(APIRoute): def get_route_handler(self) -> Callable:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 973 bytes - Viewed (0)