Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 2 of 2 for add_process_time_header (0.14 seconds)

  1. docs_src/middleware/tutorial001_py310.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 Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 365 bytes
    - Click Count (0)
  2. fastapi/applications.py

            from typing import Awaitable, Callable
    
            from fastapi import FastAPI, Request, Response
    
            app = FastAPI()
    
    
            @app.middleware("http")
            async def add_process_time_header(
                request: Request, call_next: Callable[[Request], Awaitable[Response]]
            ) -> Response:
                start_time = time.time()
                response = await call_next(request)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Apr 01 16:16:24 GMT 2026
    - 178.6K bytes
    - Click Count (0)
Back to Top