masque_uri_template (masque v0.7.0)
View SourceGeneric URI-template engine used by MASQUE protocol facades (UDP, TCP, IP). Implements the subset of RFC 6570 that RFC 9298 and RFC 9484 require: literal segments, Level-1 name path placeholders, and the Level-3 form operator for query strings.
Two entry shapes. parse_absolute/1 accepts only absolute URI templates (scheme + authority + path), used by the CONNECT-IP client where RFC 9484 section 3 requires an absolute template. parse_pattern/1 accepts either a path+query pattern or an absolute URI (in which case only the path+query portion is used), used by servers that match against the :path pseudo-header and by legacy UDP/TCP callers that have always accepted path-only templates.
The parsed result is a template() record that can be fed to expand/2 and match/2. Variable names are atoms; variable values are always returned as binaries (percent-decoded).
Summary
Functions
Expand a template with Vars. Returns a binary: the full URI for absolute templates, just the path+query for patterns.
Match a request :path against a template. Returns the captured variables on success.
Parse an absolute URI template (scheme://authority/path). Returns {error, not_absolute} if the template has no scheme or authority.
Parse a path+query pattern, or the path+query portion of an absolute URI. Non-absolute inputs are accepted as-is.
Types
Functions
Expand a template with Vars. Returns a binary: the full URI for absolute templates, just the path+query for patterns.
Match a request :path against a template. Returns the captured variables on success.
-spec parse_absolute(binary()) -> {ok, template()} | {error, parse_error()}.
Parse an absolute URI template (scheme://authority/path). Returns {error, not_absolute} if the template has no scheme or authority.
-spec parse_pattern(binary()) -> {ok, template()} | {error, parse_error()}.
Parse a path+query pattern, or the path+query portion of an absolute URI. Non-absolute inputs are accepted as-is.