Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 12 of 12 for call_next (0.2 sec)

  1. docs/ja/docs/tutorial/middleware.md

        バックグラウンドタスク (後述) がある場合は、それらは全てのミドルウェアの *後に* 実行されます。
    
    ## ミドルウェアの作成
    
    ミドルウェアを作成するには、関数の上部でデコレータ `@app.middleware("http")` を使用します。
    
    ミドルウェア関数は以下を受け取ります:
    
    * `request`。
    * パラメータとして `request` を受け取る関数 `call_next`。
        * この関数は、対応する*path operation*に `request` を渡します。
        * 次に、対応する*path operation*によって生成された `response` を返します。
    * その後、`response` を返す前にさらに `response` を変更することもできます。
    
    ```Python hl_lines="8-9  11  14"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 12 00:06:16 GMT 2022
    - 3.8K bytes
    - Viewed (0)
  2. fastapi/applications.py

            from fastapi import FastAPI, Request
    
            app = FastAPI()
    
    
            @app.middleware("http")
            async def add_process_time_header(request: Request, call_next):
                start_time = time.time()
                response = await call_next(request)
                process_time = time.time() - start_time
                response.headers["X-Process-Time"] = str(process_time)
                return response
            ```
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top