Add FastAPI roles controller, de-duplicate app initialization for FastAPI.

This commit is contained in:
John Chilton
2020-12-22 11:18:31 +01:00
committed by mvdbeek
parent 672ccb0929
commit 16951e4176
4 changed files with 68 additions and 17 deletions
+2 -10
View File
@@ -1,6 +1,4 @@
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
from galaxy_main import (
GalaxyConfigBuilder,
main,
@@ -8,6 +6,7 @@ from galaxy_main import (
from galaxy.util.properties import load_app_properties
from galaxy.webapps.galaxy.buildapp import app_factory
from galaxy.webapps.galaxy.fast_app import initialize_fast_app
app = FastAPI()
@@ -17,14 +16,7 @@ def wsgiloop(args, log):
kwds = config_builder.app_kwds()
kwds = load_app_properties(**kwds)
gx = app_factory(global_conf=config_builder.global_conf(), **kwds)
wsgi_handler = WSGIMiddleware(gx)
# app factory will import api controllers while passing in app object,
# this needs to happen before we can import the router from individual api modules
# (until we've replaced everything with FastAPI, at which point we can do normal imports).
from galaxy.webapps.galaxy.api import jobs
app.include_router(jobs.router, prefix='/api/jobs')
app.mount('/', wsgi_handler)
initialize_fast_app(gx, app=app)
uvicorn.run(app)