from fastapi import FastAPI, Request from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint from starlette.responses import Response import time class TimeHeaderMiddleware(BaseHTTPMiddleware) : async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response: return await super().dispatch(request, call_next)