# `Urchin.URITemplate`
[🔗](https://github.com/urth-inc/urchin/blob/v0.4.0/lib/urchin/uri_template.ex#L1)

Minimal RFC 6570 URI template matching used to route `resources/read` requests to
a declared `resource_template`.

Supports level-1 `{var}` expressions. A bare `{var}` matches a single path segment
(no `/`); `{+var}` and `{var*}` match across segments. This is sufficient for the
common resource-template patterns; full RFC 6570 expansion is intentionally not
implemented.

# `compile`

```elixir
@spec compile(String.t()) :: {Regex.t(), [String.t()]}
```

Compiles a URI template into a `{regex, var_names}` pair for repeated matching.

# `match`

```elixir
@spec match(String.t() | {Regex.t(), [String.t()]}, String.t()) ::
  {:ok, %{required(String.t()) =&gt; String.t()}} | :error
```

Matches `uri` against `template`, returning extracted variables on success.

Accepts either a raw template string or a precompiled `{regex, vars}` tuple.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
