URITemplateBuilder¶
A convenience builder for one-shot URI template expansion.
Combines template parsing, variable binding, and expansion into a single fluent chain. Use this when you need to expand a template once and don't need to reuse the parsed template or inspect parse errors.
For repeated expansion of the same template, parse once with URITemplate
and call expand() multiple times. For detailed parse error reporting, use
URITemplateParse.
let uri = URITemplateBuilder("{scheme}://{host}{/path*}")
.set("scheme", "https")
.set("host", "example.com")
.set_list("path", ["api"; "v1"; "users"])
.build()?
// => "https://example.com/api/v1/users"
Constructors¶
create¶
Create a builder for the given URI template string.
The template is not parsed until build() is called, so construction
always succeeds.
Parameters¶
- template: String val
Returns¶
- URITemplateBuilder ref^
Public Functions¶
set¶
Bind a string variable. Returns this builder for chaining.
Parameters¶
Returns¶
set_list¶
Bind a list variable. Returns this builder for chaining.
Parameters¶
Returns¶
set_pairs¶
Bind an associative array variable. Returns this builder for chaining.
fun ref set_pairs(
name: String val,
pairs: Array[(String val , String val)] val)
: URITemplateBuilder ref
Parameters¶
Returns¶
build¶
Parse the template and expand it with the bound variables.
Raises an error if the template has invalid syntax. Use URITemplateParse
instead when you need a description of what went wrong.
Returns¶
- String iso^ ?