GitHub

UriTemplate

API reference for UriTemplate.

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

AttributeTypeDescription
uri_templatestr
namestuple[str, ...]
schemastuple[S.Top, ...]
routerRouter[None]

Functions

__init__

__init__(uri_template, names, schemas, router) -> None
ParameterTypeDescription
uri_templatestr
namestuple[str, ...]
schemastuple[S.Top, ...]
routerRouter[None]

match

match(uri) -> Mapping[str, str] | None
ParameterTypeDescription
uristr

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()}