Skip to content

Commit d058712

Browse files
committed
Fix automatic router detection in main()
1 parent f4c56ad commit d058712

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from fastapi import APIRouter, FastAPI
55
from fastapi.middleware.cors import CORSMiddleware
66

7-
from app import lifespan_func
7+
from app import lifespan_func, logger
88

99

1010
def scan_and_include_routers(app: FastAPI) -> None:
@@ -15,10 +15,8 @@ def scan_and_include_routers(app: FastAPI) -> None:
1515
module = importlib.import_module(f"{package_module_name}.{module_name}")
1616
for attr_name in dir(module):
1717
attr = getattr(module, attr_name)
18-
if (
19-
isinstance(attr, APIRouter)
20-
and getattr(attr, "__module__", None) == module.__name__
21-
):
18+
if isinstance(attr, APIRouter):
19+
logger.info(f"Including router from {module.__name__}")
2220
app.include_router(attr)
2321

2422

0 commit comments

Comments
 (0)