Source code for debug_toolbar.litestar.panels.routes

"""Routes panel for displaying Litestar application routes."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, ClassVar

from debug_toolbar.core.panel import Panel

if TYPE_CHECKING:
    from debug_toolbar.core.context import RequestContext


[docs] class RoutesPanel(Panel): """Panel displaying Litestar application routes. Shows: - All registered routes - HTTP methods for each route - Handler names - Route parameters """ panel_id: ClassVar[str] = "RoutesPanel" title: ClassVar[str] = "Routes" template: ClassVar[str] = "panels/routes.html" has_content: ClassVar[bool] = True nav_title: ClassVar[str] = "Routes"
[docs] async def generate_stats(self, context: RequestContext) -> dict[str, Any]: """Generate route statistics.""" routes_info = context.metadata.get("routes", []) return { "routes": routes_info, "route_count": len(routes_info), "current_route": context.metadata.get("matched_route", ""), }
[docs] def get_nav_subtitle(self) -> str: """Get the navigation subtitle.""" return ""