Noizu.MCP.UriTemplate (Noizu MCP v0.1.3)

Copy Markdown View Source

Minimal RFC 6570 (level 1) URI template support: simple {var} expressions.

iex> Noizu.MCP.UriTemplate.match("db://{table}/schema", "db://users/schema")
{:ok, %{table: "users"}}

iex> Noizu.MCP.UriTemplate.match("db://{table}/schema", "db://users/data")
:nomatch

Summary

Functions

Expand a template with the given variables.

Match a URI against a template; returns captured variables atom-keyed.

Variable names (atoms) appearing in a template, in order.

Functions

expand(template, vars)

@spec expand(String.t(), map()) :: String.t()

Expand a template with the given variables.

match(template, uri)

@spec match(String.t(), String.t()) :: {:ok, map()} | :nomatch

Match a URI against a template; returns captured variables atom-keyed.

variables(template)

@spec variables(String.t()) :: [atom()]

Variable names (atoms) appearing in a template, in order.