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

Method matches

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

Source from the content-addressed store, hash-verified

469 return getattr(self.app, "routes", [])
470
471 def matches(self, scope: Scope) -> tuple[Match, Scope]:
472 if scope["type"] in ("http", "websocket"): # pragma:no branch
473 headers = Headers(scope=scope)
474 host = headers.get("host", "").split(":")[0]
475 match = self.host_regex.match(host)
476 if match:
477 matched_params = match.groupdict()
478 for key, value in matched_params.items():
479 matched_params[key] = self.param_convertors[key].convert(value)
480 path_params = dict(scope.get("path_params", {}))
481 path_params.update(matched_params)
482 child_scope = {"path_params": path_params, "endpoint": self.app}
483 return Match.FULL, child_scope
484 return Match.NONE, {}
485
486 def url_path_for(self, name: str, /, **path_params: Any) -> URLPath:
487 if self.name is not None and name == self.name and "path" in path_params:

Callers 1

appMethod · 0.45

Calls 5

HeadersClass · 0.90
getMethod · 0.45
itemsMethod · 0.45
convertMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected