File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77` urlpath ` provides a way to parse URL path elements using a schema
88
9+ For users of [ gorilla/mux] ( https://github.com/gorilla/mux ) .
10+
911### Getting Started
1012
1113The ` urlpath ` package can be added to a project by running:
@@ -14,6 +16,36 @@ The `urlpath` package can be added to a project by running:
1416go get cattlecloud.net/go/urlpath@latest
1517```
1618
19+ ``` go
20+ import " cattlecloud.net/go/urlpath"
21+ ```
22+
23+ ### Examples
24+
25+ ##### mux definition
26+
27+ Make use of gorilla's path variables.
28+
29+ ``` go
30+ router.Handle (" /v1/{category}/{name}, newHandler())
31+ ```
32+
33+ ##### parsing schema
34+
35+ Create a `Schema` and call `Parse` to extract the path variables.
36+
37+ ```go
38+ var (
39+ category int
40+ name string
41+ )
42+
43+ err := urlpath.Parse(request, urlpath.Schema {
44+ " category" : urlpath.Int(&category),
45+ " name" : urlpath.String(&name),
46+ })
47+ ```
48+
1749### License
1850
1951The `cattlecloud.net/go/urlpath` module is open source under the [BSD](LICENSE) license.
You can’t perform that action at this time.
0 commit comments