MCPcopy
hub / github.com/fastapi/fastapi / _match

Method _match

fastapi/routing.py:2107–2128  ·  view source on GitHub ↗
(
        self, scope: Scope, *, prefix: str
    )

Source from the content-addressed store, hash-verified

2105 return match, child_scope
2106
2107 def _match(
2108 self, scope: Scope, *, prefix: str
2109 ) -> tuple[Match, Scope, _FrontendRoute | None]:
2110 full: tuple[Scope, _FrontendRoute, int] | None = None
2111 partial: tuple[Scope, _FrontendRoute, int] | None = None
2112 for route in self.routes:
2113 path = _join_frontend_paths(prefix, route.path)
2114 match, child_scope = route.matches_with_path(scope, path)
2115 specificity = _frontend_path_specificity(path)
2116 if match == Match.FULL:
2117 if full is None or specificity > full[2]:
2118 full = (child_scope, route, specificity)
2119 elif match == Match.PARTIAL:
2120 if partial is None or specificity > partial[2]:
2121 partial = (child_scope, route, specificity)
2122 if full is not None:
2123 child_scope, route, _ = full
2124 return Match.FULL, child_scope, route
2125 if partial is not None:
2126 child_scope, route, _ = partial
2127 return Match.PARTIAL, child_scope, route
2128 return Match.NONE, {}, None
2129
2130 async def handle(self, scope: Scope, receive: Receive, send: Send) -> None:
2131 effective_context = _get_scope_effective_route_context(scope)

Callers 3

matchesMethod · 0.95
matches_with_prefixMethod · 0.95
handleMethod · 0.95

Calls 3

_join_frontend_pathsFunction · 0.85
matches_with_pathMethod · 0.80

Tested by

no test coverage detected