INNER CODE UNIT · Python
get_matching_route_path
stephenhillier/starlette_exporter · starlette_exporter/middleware.py:77
def get_matching_route_path(
scope: Dict[Any, Any],
routes: List[BaseRoute],
route_name: Optional[str] = None,
) -> Optional[str]:
"""
Find a matching route and return its original path string
Will attempt to enter mounted routes and subrouters.
Credit to https://github.com/elastic/apm-agent-python
"""
for route in _flatten_routes(routes):
# Route subclasses and FastAPI's effective route contexts can provide
# matching behavior beyond Starlette's base Route implementation.
match, child_scope = route.matches(scope)
if match == Match.FULL: