uritemplate.go is a Go implementation of URI Template [RFC6570] with full functionality of URI Template Level 4.
package main
import (
"fmt"
"github.com/yosida95/uritemplate.go"
)
var (
tmpl = uritemplate.MustNew("https://example.com/dictionary/{term:1}/{term}")
)
func main() {
vars := uritemplate.Values{}
vars.Set("term", uritemplate.String("cat"))
ret, err := tmpl.Expand(vars)
if err != nil{
fmt.Println(err)
return
}
fmt.Println(ret)
// Output:
// https://example.com/dictionary/c/cat
}
$ go get -u github.com/yosida95/uritemplate.go
The documentation is available on GoDoc.
uritemplate.go is distributed under the BSD 3-Clause license. PLEASE read ./LICENSE carefully and follow its clauses to use this software.