class UriTemplate[*Ts]
A resource URI template with typed parameters (Effect's tagged
template registerResource`...```), made by uri_template. A URI is matched as Effect matches it, by find-my-way on /`` + the URI: each
parameter one percent-decoded path segment, the query and fragment
left out, duplicate and trailing slashes ignored.
Attributes#
| Attribute | Type | Description |
|---|---|---|
uri_template | str | |
names | tuple[str, ...] | |
schemas | tuple[S.Top, ...] | |
router | Router[None] |
Functions#
__init__#
__init__(uri_template, names, schemas, router) -> None| Parameter | Type | Description |
|---|---|---|
uri_template | str | |
names | tuple[str, ...] | |
schemas | tuple[S.Top, ...] | |
router | Router[None] |
match#
match(uri) -> Mapping[str, str] | None| Parameter | Type | Description |
|---|---|---|
uri | str |
Returns Mapping[str, str] | None
def match(self, uri: str) -> Mapping[str, str] | None:
found = self.router.find("GET", f"/{uri}")
if found is None:
return None
return {self.names[int(index)]: value for index, value in found.params.items()}