Refactor: Modularize middleware and router registration in app/main.py

This commit is contained in:
Scott Idem
2026-01-15 16:36:19 -05:00
parent d321b94395
commit 2227432970
3 changed files with 95 additions and 364 deletions

12
app/middleware.py Normal file
View File

@@ -0,0 +1,12 @@
import time
from fastapi import Request
async def add_process_time_header(request: Request, call_next):
"""
Middleware to add the processing time to the response header.
"""
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