|
|
@@ -48,8 +48,19 @@ async def _lifespan(app: FastAPI):
|
|
|
await task
|
|
|
|
|
|
|
|
|
+_log = __import__('logging').getLogger(__name__)
|
|
|
+
|
|
|
+
|
|
|
def create_app() -> FastAPI:
|
|
|
+ from caldav.lib.error import AuthorizationError
|
|
|
+
|
|
|
app = FastAPI(title='room_cal', lifespan=_lifespan)
|
|
|
+
|
|
|
+ @app.exception_handler(AuthorizationError)
|
|
|
+ async def _caldav_auth_error(request: Request, exc: AuthorizationError):
|
|
|
+ _log.error('caldav: %s', exc)
|
|
|
+ return JSONResponse({'detail': str(exc)}, status_code=500)
|
|
|
+
|
|
|
app.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=['*'], allow_headers=['*'])
|
|
|
app.add_middleware(_AuthMiddleware)
|
|
|
app.include_router(auth_router)
|