add middleware when initializing fastapi

This commit is contained in:
koid
2023-11-05 15:38:19 +09:00
parent 194bfe1193
commit e6ef123ce5

View File

@ -1,12 +1,15 @@
from fastapi import FastAPI
from mangum import Mangum
from starlette.middleware import Middleware
from starlette_context.middleware import RawContextMiddleware
from pr_agent.log import setup_logger
from pr_agent.servers.github_app import router
setup_logger()
app = FastAPI()
middleware = [Middleware(RawContextMiddleware)]
app = FastAPI(middleware=middleware)
app.include_router(router)
handler = Mangum(app, lifespan="off")