Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 46 for Wadler (0.2 sec)

  1. docs_src/custom_request_and_route/tutorial002.py

    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:
                    return await original_route_handler(request)
                except RequestValidationError as exc:
                    body = await request.body()
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 932 bytes
    - Viewed (0)
  2. docs/en/docs/how-to/custom-request-and-route.md

    ## Accessing the request body in an exception handler
    
    !!! tip
        To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body){.internal-link target=_blank}).
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Mar 31 23:52:53 GMT 2024
    - 4.4K bytes
    - Viewed (0)
  3. docs_src/handling_errors/tutorial003.py

    from fastapi.responses import JSONResponse
    
    
    class UnicornException(Exception):
        def __init__(self, name: str):
            self.name = name
    
    
    app = FastAPI()
    
    
    @app.exception_handler(UnicornException)
    async def unicorn_exception_handler(request: Request, exc: UnicornException):
        return JSONResponse(
            status_code=418,
            content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
        )
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 626 bytes
    - Viewed (0)
  4. tests/test_enforce_once_required_parameter.py

    
    def _get_client_tag(client_id: Optional[str] = Query(None)) -> Optional[str]:
        if client_id is None:
            return None
        return f"{client_id}_tag"
    
    
    @app.get("/foo")
    def foo_handler(
        client_key: str = Depends(_get_client_key),
        client_tag: Optional[str] = Depends(_get_client_tag),
    ):
        return {"client_id": client_key, "client_tag": client_tag}
    
    
    client = TestClient(app)
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.4K bytes
    - Viewed (0)
  5. docs/em/docs/tutorial/dependencies/dependencies-with-yield.md

        opt raise
            dep -->> handler: Raise HTTPException
            handler -->> client: HTTP error response
            dep -->> dep: Raise other exception
        end
        dep ->> operation: Run dependency, e.g. DB session
        opt raise
            operation -->> dep: Raise HTTPException
            dep -->> handler: Auto forward exception
            handler -->> client: HTTP error response
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 8.6K bytes
    - Viewed (0)
  6. tests/test_ws_router.py

    
    def test_depend_err_handler():
        """
        Verify that it is possible to write custom WebSocket middleware to catch errors
        """
    
        async def custom_handler(websocket: WebSocket, exc: CustomError) -> None:
            await websocket.close(1002, "foo")
    
        myapp = make_app(exception_handlers={CustomError: custom_handler})
        client = TestClient(myapp)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  7. docs/em/docs/how-to/custom-request-and-route.md

    {!../../../docs_src/custom_request_and_route/tutorial001.py!}
    ```
    
    ### ✍ 🛃 `GzipRoute` 🎓
    
    ⏭, 👥 ✍ 🛃 🏿 `fastapi.routing.APIRoute` 👈 🔜 ⚒ ⚙️ `GzipRequest`.
    
    👉 🕰, ⚫️ 🔜 📁 👩‍🔬 `APIRoute.get_route_handler()`.
    
    👉 👩‍🔬 📨 🔢. & 👈 🔢 ⚫️❔ 🔜 📨 📨 & 📨 📨.
    
    📥 👥 ⚙️ ⚫️ ✍ `GzipRequest` ⚪️➡️ ⏮️ 📨.
    
    ```Python hl_lines="18-26"
    {!../../../docs_src/custom_request_and_route/tutorial001.py!}
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  8. docs/fr/docs/async.md

    À la place, en étant "asynchrone", une fois terminée, une tâche peut légèrement attendre (quelques microsecondes) que l'ordinateur / le programme finisse ce qu'il était en train de faire, et revienne récupérer le résultat.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Mar 31 23:52:53 GMT 2024
    - 24K bytes
    - Viewed (0)
  9. docs/en/docs/release-notes.md

        opt raise
            dep -->> handler: Raise HTTPException
            handler -->> client: HTTP error response
            dep -->> dep: Raise other exception
        end
        dep ->> operation: Run dependency, e.g. DB session
        opt raise
            operation -->> dep: Raise HTTPException
            dep -->> handler: Auto forward exception
            handler -->> client: HTTP error response
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Apr 28 00:28:00 GMT 2024
    - 385.5K bytes
    - Viewed (1)
  10. docs/en/docs/tutorial/handling-errors.md

    When a request contains invalid data, **FastAPI** internally raises a `RequestValidationError`.
    
    And it also includes a default exception handler for it.
    
    To override it, import the `RequestValidationError` and use it with `@app.exception_handler(RequestValidationError)` to decorate the exception handler.
    
    The exception handler will receive a `Request` and the exception.
    
    ```Python hl_lines="2  14-16"
    {!../../../docs_src/handling_errors/tutorial004.py!}
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
Back to top