🩹 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
|
||||
for app_name, app_def in self._apps.items():
|
||||
if app_def.router:
|
||||
app.include_router(app_def.router)
|
||||
for router in app_def.routers:
|
||||
app.include_router(router)
|
||||
|
||||
# Startup / shutdown events
|
||||
@app.on_event("startup")
|
||||
|
|
@ -333,14 +333,21 @@ class App:
|
|||
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
|
||||
def routes(self):
|
||||
"""
|
||||
Return an APIRouter with all loaded routes.
|
||||
"""
|
||||
router = APIRouter()
|
||||
for routes_mod in self._routers:
|
||||
for r in self._routers[routes_mod]:
|
||||
for r in self.routers:
|
||||
router.include_router(r)
|
||||
return router.routes
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue