🩹 Fix FastAPI app initialization
This commit is contained in:
parent
ee4bd2760c
commit
af110cec9d
1 changed files with 12 additions and 5 deletions
|
|
@ -81,8 +81,8 @@ class Project:
|
||||||
|
|
||||||
# Attach routers from apps
|
# Attach routers from apps
|
||||||
for app_name, app_def in self._apps.items():
|
for app_name, app_def in self._apps.items():
|
||||||
if app_def.router:
|
for router in app_def.routers:
|
||||||
app.include_router(app_def.router)
|
app.include_router(router)
|
||||||
|
|
||||||
# Startup / shutdown events
|
# Startup / shutdown events
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
|
|
@ -333,14 +333,21 @@ class App:
|
||||||
module: out,
|
module: out,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def routers(self):
|
||||||
|
out = []
|
||||||
|
for routes_mod in self._routers:
|
||||||
|
for r in self._routers[routes_mod]:
|
||||||
|
out.append(r)
|
||||||
|
return out
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def routes(self):
|
def routes(self):
|
||||||
"""
|
"""
|
||||||
Return an APIRouter with all loaded routes.
|
Return an APIRouter with all loaded routes.
|
||||||
"""
|
"""
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
for routes_mod in self._routers:
|
for r in self.routers:
|
||||||
for r in self._routers[routes_mod]:
|
|
||||||
router.include_router(r)
|
router.include_router(r)
|
||||||
return router.routes
|
return router.routes
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue