An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/gorilla/pat

Package gorilla/pat is a request router and dispatcher with a pat-like interface. It is an alternative to gorilla/mux that showcases how it can be used as a base for different API flavors. Package pat is documented at: Let's start registering a couple of URL paths and handlers: Here we register three routes mapping URL paths to handlers. This is equivalent to how http.HandleFunc() works: if an incoming GET request matches one of the paths, the corresponding handler is called passing (http.ResponseWriter, *http.Request) as parameters. Note: gorilla/pat matches path prefixes, so you must register the most specific paths first. Note: differently from pat, these methods accept a handler function, and not an http.Handler. We think this is shorter and more convenient. To set an http.Handler, use the Add() method. Paths can have variables. They are defined using the format {name} or {name:pattern}. If a regular expression pattern is not defined, the matched variable will be anything until the next slash. For example: The names are used to create a map of route variables which are stored in the URL query, prefixed by a colon: As in the gorilla/mux package, other matchers can be added to the registered routes and URLs can be reversed as well. To build a URL for a route, first add a name to it: Then you can get it using the name and generate a URL: ...and the result will be a url.URL with the following path: Check the mux documentation for more details about URL building and extra matchers:

Ecosystem
proxy.golang.org
Latest Release
v1.0.2
over 2 years ago
Versions
2
Dependent Packages
281
Dependent Repos
1,213
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/gorilla/pat
spec
License BSD-3-Clause
Namespace github.com/gorilla
First Release over 6 years ago
Last Synced 6 days ago
Repository
Stars 159 on GitHub
Forks 24 on GitHub
Docker Dependents 23
Docker Downloads 485,569
Rankings on proxy.golang.org
Overall Top 2.1%
Dependent packages Top 0.3%
Dependent repos Top 0.2%
Forks Top 5.2%
Docker downloads Top 0.6%