diff --git a/etebase_fastapi/main.py b/etebase_fastapi/main.py index 69303bf..534798e 100644 --- a/etebase_fastapi/main.py +++ b/etebase_fastapi/main.py @@ -13,7 +13,7 @@ from .invitation import invitation_incoming_router, invitation_outgoing_router from .msgpack import MsgpackResponse -def create_application(prefix=""): +def create_application(prefix="", middlewares=[]): app = FastAPI( title="Etebase", description="The Etebase server API documentation", @@ -51,6 +51,9 @@ def create_application(prefix=""): ) app.add_middleware(TrustedHostMiddleware, allowed_hosts=settings.ALLOWED_HOSTS) + for middleware in middlewares: + app.add_middleware(middleware) + @app.exception_handler(CustomHttpException) async def custom_exception_handler(request: Request, exc: CustomHttpException): return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)