Swift implementation of URI Template (RFC6570)
Swift implementation of URI Template (RFC6570).
CocoaPods is the recommended installation method.
pod 'URITemplate'
let template = URITemplate(template: "https://api.github.com/repos/{owner}/{repo}/")
let url = template.expand(["owner": "kylef", "repo": "URITemplate.swift"])
=> "https://api.github.com/repos/kylef/URITemplate.swift/"
let variables = template.variables
=> ["owner", "repo"]
let variables = template.extract("https://api.github.com/repos/kylef/PathKit/")
=> ["owner":"kylef", "repo":"PathKit"]
The URITemplate library follows the test suite.
We have full support for level 4 of RFC6570 when expanding a template and retrieving the variables in a template.
For extraction of variables from an already expanded template, level 3 is supported.
URITemplate is licensed under the MIT license. See LICENSE for more
info.