mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-20 08:55:24 -04:00
edit middleware docs code sample to use perf_counter as a timer
This commit is contained in:
1 parent
df419b739c
commit
7ff5da8bf2
1 file changed
+2
-2
@@ -7,8 +7,8 @@ app = FastAPI()
|
||||
|
||||
@app.middleware("http")
|
||||
async def add_process_time_header(request: Request, call_next):
|
||||
start_time = time.time()
|
||||
start_time = time.perf_counter()
|
||||
response = await call_next(request)
|
||||
process_time = time.time() - start_time
|
||||
process_time = time.perf_counter() - start_time
|
||||
response.headers["X-Process-Time"] = str(process_time)
|
||||
return response
|
||||
Reference in new issue
Block a user