Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for call_next (0.09 sec)

  1. tests/test_ws_router.py

                    return await app(scope, receive, send)  # pragma: no cover
    
                async def call_next():
                    return await app(scope, receive, send)
    
                websocket = WebSocket(scope, receive=receive, send=send)
                return await middleware_func(websocket, call_next)
    
            return wrapped_app
    
        return middleware_constructor
    
    
    def test_depend_validation():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Jun 11 19:08:14 UTC 2023
    - 7.5K bytes
    - Viewed (0)
  2. tests/test_dependency_contextvars.py

        yield request_state
        legacy_request_state_context_var.reset(contextvar_token)
    
    
    @app.middleware("http")
    async def custom_middleware(
        request: Request, call_next: Callable[[Request], Awaitable[Response]]
    ):
        response = await call_next(request)
        response.headers["custom"] = "foo"
        return response
    
    
    @app.get("/user", dependencies=[Depends(set_up_request_state_dependency)])
    def get_user():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Feb 17 12:40:12 UTC 2022
    - 1.5K bytes
    - Viewed (0)
  3. docs_src/middleware/tutorial001.py

    import time
    
    from fastapi import FastAPI, Request
    
    app = FastAPI()
    
    
    @app.middleware("http")
    async def add_process_time_header(request: Request, call_next):
        start_time = time.perf_counter()
        response = await call_next(request)
        process_time = time.perf_counter() - start_time
        response.headers["X-Process-Time"] = str(process_time)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Aug 06 13:46:39 UTC 2024
    - 365 bytes
    - Viewed (0)
  4. tests/test_dependency_contextmanager.py

            )
    
        tasks.add_task(bg, state)
        return state
    
    
    @app.middleware("http")
    async def middleware(request, call_next):
        response: StreamingResponse = await call_next(request)
        response.headers["x-state"] = json.dumps(state.copy())
        return response
    
    
    client = TestClient(app)
    
    
    def test_async_state():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Aug 17 04:13:50 UTC 2024
    - 11.6K bytes
    - Viewed (0)
  5. docs/em/docs/tutorial/middleware.md

    🚥 👆 ✔️ 🔗 ⏮️ `yield`, 🚪 📟 🔜 🏃 *⏮️* 🛠️.
    
    🚥 📤 🙆 🖥 📋 (📄 ⏪), 👫 🔜 🏃 *⏮️* 🌐 🛠️.
    
    ///
    
    ## ✍ 🛠️
    
    ✍ 🛠️ 👆 ⚙️ 👨‍🎨 `@app.middleware("http")` 🔛 🔝 🔢.
    
    🛠️ 🔢 📨:
    
    *  `request`.
    * 🔢 `call_next` 👈 🔜 📨 `request` 🔢.
        * 👉 🔢 🔜 🚶‍♀️ `request` 🔗 *➡ 🛠️*.
        * ⤴️ ⚫️ 📨 `response` 🏗 🔗 *➡ 🛠️*.
    * 👆 💪 ⤴️ 🔀 🌅 `response` ⏭ 🛬 ⚫️.
    
    ```Python hl_lines="8-9  11  14"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.4K bytes
    - Viewed (0)
  6. docs/de/docs/tutorial/middleware.md

    ## Erstellung einer Middleware
    
    Um eine Middleware zu erstellen, verwenden Sie den Dekorator `@app.middleware("http")` über einer Funktion.
    
    Die Middleware-Funktion erhält:
    
    * Den `request`.
    * Eine Funktion `call_next`, die den `request` als Parameter erhält.
        * Diese Funktion gibt den `request` an die entsprechende *Pfadoperation* weiter.
        * Dann gibt es die von der entsprechenden *Pfadoperation* generierte `response` zurück.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.4K bytes
    - Viewed (0)
  7. docs/fa/docs/tutorial/middleware.md

    ///
    
    ## ساخت یک میان افزار
    
    برای ایجاد یک میان‌افزار، از دکوریتور `@app.middleware("http")` در بالای یک تابع استفاده می‌شود.
    
    تابع میان افزار دریافت می کند:
    * `درخواست`
    * تابع `call_next` که `درخواست` را به عنوان پارامتر دریافت می کند
        * این تابع `درخواست` را به *path operation* مربوطه ارسال می کند.
        * سپس `پاسخ` تولید شده توسط *path operation* مربوطه را برمی‌گرداند.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 4.4K bytes
    - Viewed (0)
  8. docs/en/docs/tutorial/middleware.md

    ///
    
    ## Create a middleware
    
    To create a middleware you use the decorator `@app.middleware("http")` on top of a function.
    
    The middleware function receives:
    
    * The `request`.
    * A function `call_next` that will receive the `request` as a parameter.
        * This function will pass the `request` to the corresponding *path operation*.
        * Then it returns the `response` generated by the corresponding *path operation*.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  9. docs/pt/docs/tutorial/middleware.md

    ///
    
    ## Criar um middleware
    
    Para criar um middleware, use o decorador `@app.middleware("http")` logo acima de uma função.
    
    A função middleware recebe:
    
    * A `request`.
    * Uma função `call_next` que receberá o `request` como um parâmetro.
        * Esta função passará a `request` para a *operação de rota* correspondente.
        * Então ela retorna a `response` gerada pela *operação de rota* correspondente.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  10. docs/ko/docs/tutorial/middleware.md

    ///
    
    ## 미들웨어 만들기
    
    미들웨어를 작성하기 위해서 함수 상단에 `@app.middleware("http")` 데코레이터를 사용할 수 있습니다.
    
    미들웨어 함수는 다음 항목들을 받습니다:
    
    * `request`.
    * `request`를 매개변수로 받는 `call_next` 함수.
        * 이 함수는 `request`를 해당하는 *경로 작업*으로 전달합니다.
        * 그런 다음, *경로 작업*에 의해 생성된 `response` 를 반환합니다.
    * `response`를 반환하기 전에 추가로 `response`를 수정할 수 있습니다.
    
    ```Python hl_lines="8-9  11  14"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.4K bytes
    - Viewed (0)
Back to top