Extracts path variables from URLs.
package main
import (
"fmt"
"net/http"
"github.com/a-h/pathvars"
)
var matcher = pathvars.NewExtractor("/user/{userid}")
func main() {
r, _ := http.NewRequest("GET", "/user/123", nil)
values, ok := matcher.Extract(r.URL)
fmt.Println("OK:", ok)
fmt.Println("User ID:", values["userid"])
}
$ go run main.go
OK: true
User ID: 123