From c06a81503fa2227ce9f6eded0795b5d820456317 Mon Sep 17 00:00:00 2001 From: Slipstream Date: Wed, 14 May 2025 17:16:12 -0600 Subject: [PATCH] feat: Enhance route logging to include mounted apps and unknown route types for better debugging --- api_service/api_server.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/api_service/api_server.py b/api_service/api_server.py index d822763..5a65ca8 100644 --- a/api_service/api_server.py +++ b/api_service/api_server.py @@ -525,8 +525,14 @@ try: app.mount("/webhook", webhook_router) # Mount directly on the main app for simplicity # After mounting the webhook router log.info("Available routes in webhook_router:") + from fastapi.routing import APIRoute, Mount for route in webhook_router.routes: - log.info(f" {route.path} - {route.name} - {route.methods}") + if isinstance(route, APIRoute): + log.info(f" {route.path} - {route.name} - {route.methods}") + elif isinstance(route, Mount): + log.info(f" {route.path} - {route.name} - Mounted app or static files") + else: + log.info(f" {route.path} - {route.name} - Unknown route type") # Or, if you prefer to nest it under /api: # api_app.include_router(webhook_router, prefix="/webhooks", tags=["Webhooks"]) log.info("Webhook endpoints loaded and mounted successfully at /webhook") @@ -551,8 +557,14 @@ except ImportError as e: # Log the available routes for debugging log.info("Available routes in dashboard_api_app:") +from fastapi.routing import APIRoute, Mount for route in dashboard_api_app.routes: - log.info(f" {route.path} - {route.name} - {route.methods}") + if isinstance(route, APIRoute): + log.info(f" {route.path} - {route.name} - {route.methods}") + elif isinstance(route, Mount): + log.info(f" {route.path} - {route.name} - Mounted app or static files") + else: + log.info(f" {route.path} - {route.name} - Unknown route type") # Create a middleware for redirecting /discordapi to /api with a deprecation warning class DeprecationRedirectMiddleware(BaseHTTPMiddleware): @@ -610,8 +622,14 @@ async def verify_discord_token(authorization: str = Header(None)) -> str: # Log the available routes for debugging log.info("Available routes in main app:") +from fastapi.routing import APIRoute, Mount for route in app.routes: - log.info(f" {route.path} - {route.name} - {route.methods}") + if isinstance(route, APIRoute): + log.info(f" {route.path} - {route.name} - {route.methods}") + elif isinstance(route, Mount): + log.info(f" {route.path} - {route.name} - Mounted app or static files") + else: + log.info(f" {route.path} - {route.name} - Unknown route type") @app.get("/") async def root():