MCPcopy
hub / github.com/encode/starlette / matches

Method matches

starlette/routing.py:323–336  ·  view source on GitHub ↗
(self, scope: Scope)

Source from the content-addressed store, hash-verified

321 self.path_regex, self.path_format, self.param_convertors = compile_path(path)
322
323 def matches(self, scope: Scope) -> tuple[Match, Scope]:
324 path_params: dict[str, Any]
325 if scope["type"] == "websocket":
326 route_path = get_route_path(scope)
327 match = self.path_regex.match(route_path)
328 if match:
329 matched_params = match.groupdict()
330 for key, value in matched_params.items():
331 matched_params[key] = self.param_convertors[key].convert(value)
332 path_params = dict(scope.get("path_params", {}))
333 path_params.update(matched_params)
334 child_scope = {"endpoint": self.endpoint, "path_params": path_params}
335 return Match.FULL, child_scope
336 return Match.NONE, {}
337
338 def url_path_for(self, name: str, /, **path_params: Any) -> URLPath:
339 seen_params = set(path_params.keys())

Callers

nothing calls this directly

Calls 5

get_route_pathFunction · 0.90
itemsMethod · 0.45
convertMethod · 0.45
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected