Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
```python
import time
+ from typing import Awaitable, Callable
- from fastapi import FastAPI, Request
+ from fastapi import FastAPI, Request, Response
app = FastAPI()
@app.middleware("http")
- async def add_process_time_header(request: Request, call_next):
+ async def add_process_time_header(
+ request: Request, call_next: Callable[[Request], Awaitable[Response]]
+ ) -> Response:
start_time = time.time()
response = await call_next(request)
process_time = time.time() - start_time