Skip to content

urlpath is a Go package with generics for extracting values from URL path elements

License

Notifications You must be signed in to change notification settings

cattlecloud/urlpath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlpath

Go Reference License Build

urlpath provides a way to parse URL path elements using a schema

For users of gorilla/mux.

Getting Started

The urlpath package can be added to a project by running:

go get cattlecloud.net/go/urlpath@latest
import "cattlecloud.net/go/urlpath"

Examples

mux definition

Make use of gorilla's path variables.

router.Handle("/v1/{category}/{name}, newHandler())
parsing schema

Create a Schema and call Parse to extract the path variables.

var (
  category int
  name     string
)

err := urlpath.Parse(request, urlpath.Schema {
  "category": urlpath.Int(&category),
  "name":     urlpath.String(&name),
})

License

The cattlecloud.net/go/urlpath module is open source under the BSD license.