{"size": 1482, "ext": "scrbl", "max_stars_repo_path": "doc/utils/rfc/uri-template.scrbl", "max_stars_repo_name": "christoff-buerger/sagittarius-scheme", "max_stars_repo_stars_event_min_datetime": "2015-11-07T07:13:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T03:35:14.000Z", "max_issues_repo_path": "doc/utils/rfc/uri-template.scrbl", "max_issues_repo_name": "christoff-buerger/sagittarius-scheme", "max_issues_repo_issues_event_min_datetime": "2016-04-28T21:59:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:42:21.000Z", "max_forks_repo_path": "doc/utils/rfc/uri-template.scrbl", "max_forks_repo_name": "christoff-buerger/sagittarius-scheme", "max_forks_repo_forks_event_min_datetime": "2016-12-28T12:41:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-26T20:52:02.000Z"}
{"max_stars_count": 39, "max_issues_count": 3, "max_forks_count": 4, "avg_line_length": 30.2448979592, "max_line_length": 104, "alphanum_fraction": 0.6619433198}
@; -*- coding: utf-8 -*-
@subsection[:tag "rfc.uri-template"]{(rfc uri-template) - URI template}

@define[Library]{@name{(rfc uri-template)}}
@desc{This library provides RFC6570 'URI Template' procedures.}

@define[Function]{@name{parse-uri-template} @args{in}}
@desc{Parses the given URI template into S-expression.

The given @var{in} must be either a textual input port or a string.

The parsed form consists with the following rules:

@itemlist[
@item{uri-template ::= @code{(template-unit)}}
@item{template-unit ::= @code{string}}
@item{template-unit ::= @code{(template)}}
@item{template ::= @code{(operator varaible)}}
@item{operator ::= @code{character}}
@item{variable ::= @code{string}}
@item{variable ::= @code{(string modifier)}}
@item{modifier ::= @code{*}}
@item{modifier ::= @code{positive exact integer}}
]

@var{operator} must be a valid URI template operator

@snipet[=> ("http://" (("domain" *)) "/" (#\/ "path"))]{
(parse-uri-template "http://{domain*}/{/path}")
}
}

@define[Function]{@name{expand-uri-template} @args{uri-template parameter}}
@desc{Expands the given @var{uri-template} and returns a string.

The @var{parameter} must be a vector of pair of string and @var{value}.

The @var{value} must be one of the followings:
@itemlist[
@item{string}
@item{list of string}
@item{vector of pair of string}
]

@snipet[=> "?semi=%3B&dot=.&comma=%2C"]{
(expand-uri-template '((#\? ("keys" *))) '#(("keys" . #(("semi" . ";") ("dot" . ".") ("comma" . ",")))))
}
}
