Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 21 - 30 of 59 for apiNote (0.06 seconds)

  1. docs_src/custom_request_and_route/tutorial001_py310.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:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 976 bytes
    - Click Count (0)
  2. docs_src/custom_request_and_route/tutorial001_an_py310.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:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 1015 bytes
    - Click Count (0)
  3. docs/ja/docs/how-to/custom-request-and-route.md

    # カスタム Request と APIRoute クラス { #custom-request-and-apiroute-class }
    
    場合によっては、`Request` や `APIRoute` クラスで使われるロジックを上書きしたいことがあります。
    
    特に、ミドルウェアでのロジックの代替として有効な場合があります。
    
    たとえば、アプリケーションで処理される前にリクエストボディを読み取ったり操作したりしたい場合です。
    
    /// danger | 警告
    
    これは「上級」機能です。
    
    FastAPI を始めたばかりの場合は、このセクションは読み飛ばしてもよいでしょう。
    
    ///
    
    ## ユースケース { #use-cases }
    
    ユースケースの例:
    
    * JSON ではないリクエストボディを JSON に変換する(例: [`msgpack`](https://msgpack.org/index.html))。
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 5.4K bytes
    - Click Count (0)
  4. 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}")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Sep 29 03:29:38 GMT 2025
    - 1.5K bytes
    - Click Count (0)
  5. docs_src/custom_request_and_route/tutorial002_an_py310.py

    from typing import Annotated
    
    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:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 974 bytes
    - Click Count (0)
  6. docs_src/generate_clients/tutorial003_py310.py

    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
    
    
    class User(BaseModel):
        username: str
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 914 bytes
    - Click Count (0)
  7. fastapi/utils.py

    from fastapi.exceptions import FastAPIDeprecationWarning, PydanticV1NotSupportedError
    from pydantic.fields import FieldInfo
    
    from ._compat import v2
    
    if TYPE_CHECKING:  # pragma: nocover
        from .routing import APIRoute
    
    
    def is_body_allowed_for_status_code(status_code: int | str | None) -> bool:
        if status_code is None:
            return True
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 11 18:41:21 GMT 2026
    - 4.2K bytes
    - Click Count (0)
  8. tests/test_generate_unique_id_function.py

    from fastapi.routing import APIRoute
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    from pydantic import BaseModel
    
    
    def custom_generate_unique_id(route: APIRoute):
        return f"foo_{route.name}"
    
    
    def custom_generate_unique_id2(route: APIRoute):
        return f"bar_{route.name}"
    
    
    def custom_generate_unique_id3(route: APIRoute):
        return f"baz_{route.name}"
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 75K bytes
    - Click Count (0)
  9. fastapi/routing.py

            route_class: Annotated[
                type[APIRoute],
                Doc(
                    """
                    Custom route (*path operation*) class to be used by this router.
    
                    Read more about it in the
                    [FastAPI docs for Custom Request and APIRoute class](https://fastapi.tiangolo.com/how-to/custom-request-and-route/#custom-apiroute-class-in-a-router).
                    """
                ),
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 193K bytes
    - Click Count (0)
  10. src/archive/zip/struct.go

    for normal archives both fields will be the same. For files requiring
    the ZIP64 format the 32 bit fields will be 0xffffffff and the 64 bit
    fields must be used instead.
    
    [ZIP specification]: https://support.pkware.com/pkzip/appnote
    */
    package zip
    
    import (
    	"io/fs"
    	"path"
    	"time"
    )
    
    // Compression methods.
    const (
    	Store   uint16 = 0 // no compression
    	Deflate uint16 = 8 // DEFLATE compressed
    )
    
    const (
    Created: Tue Apr 07 11:13:11 GMT 2026
    - Last Modified: Tue May 28 21:41:09 GMT 2024
    - 12.1K bytes
    - Click Count (0)
Back to Top