Change how we create applications.

This commit is contained in:
Tom Hacohen 2020-12-28 14:47:41 +02:00
parent 65cd722616
commit c1f171bde0
2 changed files with 25 additions and 21 deletions

View File

@ -12,9 +12,10 @@ from .member import member_router
from .invitation import invitation_incoming_router, invitation_outgoing_router
from .msgpack import MsgpackResponse
def create_application(prefix=""):
app = FastAPI()
VERSION = "v1"
BASE_PATH = f"/api/{VERSION}"
BASE_PATH = f"{prefix}/api/{VERSION}"
COLLECTION_UID_MARKER = "{collection_uid}"
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"])
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection", tags=["collection"])
@ -37,3 +38,4 @@ app.add_middleware(TrustedHostMiddleware, allowed_hosts=settings.ALLOWED_HOSTS)
@app.exception_handler(CustomHttpException)
async def custom_exception_handler(request: Request, exc: CustomHttpException):
return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)
return app

View File

@ -7,7 +7,9 @@ django_application = get_asgi_application()
def create_application():
from etebase_fastapi.main import app
from etebase_fastapi.main import create_application
app = create_application()
app.mount("/", django_application)