MCPcopy Index your code
hub / github.com/fastapi/fastapi / matches_with_path

Method matches_with_path

fastapi/routing.py:2029–2043  ·  view source on GitHub ↗
(self, scope: Scope, path: str)

Source from the content-addressed store, hash-verified

2027 return self.matches_with_path(scope, self.path)
2028
2029 def matches_with_path(self, scope: Scope, path: str) -> tuple[Match, Scope]:
2030 if scope["type"] != "http":
2031 return Match.NONE, {}
2032 frontend_path = self._get_frontend_path(path, get_route_path(scope))
2033 if frontend_path is None:
2034 return Match.NONE, {}
2035 child_scope = {
2036 _FASTAPI_SCOPE_KEY: {
2037 _FASTAPI_FRONTEND_PATH_KEY: frontend_path,
2038 _FASTAPI_FRONTEND_SPECIFICITY_KEY: _frontend_path_specificity(path),
2039 }
2040 }
2041 if scope["method"] not in self.methods:
2042 return Match.PARTIAL, child_scope
2043 return Match.FULL, child_scope
2044
2045 def _get_frontend_path(self, path: str, route_path: str) -> str | None:
2046 if path == "/":

Callers 2

matchesMethod · 0.95
_matchMethod · 0.80

Calls 2

_get_frontend_pathMethod · 0.95

Tested by

no test coverage detected