Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 1 of 1 for add_process_time_header (0.07 seconds)

  1. docs_src/middleware/tutorial001_py39.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)
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 365 bytes
    - Click Count (0)
Back to Top