Change how we create applications.

master
Tom Hacohen 4 years ago
parent 65cd722616
commit c1f171bde0

@ -12,9 +12,10 @@ from .member import member_router
from .invitation import invitation_incoming_router, invitation_outgoing_router from .invitation import invitation_incoming_router, invitation_outgoing_router
from .msgpack import MsgpackResponse from .msgpack import MsgpackResponse
def create_application(prefix=""):
app = FastAPI() app = FastAPI()
VERSION = "v1" VERSION = "v1"
BASE_PATH = f"/api/{VERSION}" BASE_PATH = f"{prefix}/api/{VERSION}"
COLLECTION_UID_MARKER = "{collection_uid}" COLLECTION_UID_MARKER = "{collection_uid}"
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"]) app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"])
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection", tags=["collection"]) 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) @app.exception_handler(CustomHttpException)
async def custom_exception_handler(request: Request, exc: CustomHttpException): async def custom_exception_handler(request: Request, exc: CustomHttpException):
return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict) return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)
return app

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

Loading…
Cancel
Save