URI 模板的 Swift 实现 (RFC6570)。
CocoaPods 是推荐的安装方法。
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"]
URITemplate 库遵循 测试套件。
在展开模板和检索模板中的变量时,我们完全支持 RFC6570 的级别 4。
对于从已展开的模板中提取变量,我们支持级别 3。
URITemplate 基于 MIT 许可授权。有关更多信息,请参阅 LICENSE。