Ecosyste.ms: Repos
An open API service providing repository metadata for many open source software ecosystems.
Package Usage: go: github.com/gorilla/mux
Package mux implements a request router and dispatcher.
The name mux stands for "HTTP request multiplexer". Like the standard
http.ServeMux, mux.Router matches incoming requests against a list of
registered routes and calls a handler for the route that matches the URL
or other conditions. The main features are:
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 request URL matches
one of the paths, the corresponding handler is called passing
(http.ResponseWriter, *http.Request) as parameters.
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:
Groups can be used inside patterns, as long as they are non-capturing (?:re). For example:
The names are used to create a map of route variables which can be retrieved
calling mux.Vars():
Note that if any capturing groups are present, mux will panic() during parsing. To prevent
this, convert any capturing groups to non-capturing, e.g. change "/{sort:(asc|desc)}" to
"/{sort:(?:asc|desc)}". This is a change from prior versions which behaved unpredictably
when capturing groups were present.
And this is all you need to know about the basic usage. More advanced options
are explained below.
Routes can also be restricted to a domain or subdomain. Just define a host
pattern to be matched. They can also have variables:
There are several other matchers that can be added. To match path prefixes:
...or HTTP methods:
...or URL schemes:
...or header values:
...or query values:
...or to use a custom matcher function:
...and finally, it is possible to combine several matchers in a single route:
Setting the same matching conditions again and again can be boring, so we have
a way to group several routes that share the same requirements.
We call it "subrouting".
For example, let's say we have several URLs that should only match when the
host is "www.example.com". Create a route for that host and get a "subrouter"
from it:
Then register routes in the subrouter:
The three URL paths we registered above will only be tested if the domain is
"www.example.com", because the subrouter is tested first. This is not
only convenient, but also optimizes request matching. You can create
subrouters combining any attribute matchers accepted by a route.
Subrouters can be used to create domain or path "namespaces": you define
subrouters in a central place and then parts of the app can register its
paths relatively to a given subrouter.
There's one more thing about subroutes. When a subrouter has a path prefix,
the inner routes use it as base for their paths:
Note that the path provided to PathPrefix() represents a "wildcard": calling
PathPrefix("/static/").Handler(...) means that the handler will be passed any
request that matches "/static/*". This makes it easy to serve static files with mux:
Now let's see how to build registered URLs.
Routes can be named. All routes that define a name can have their URLs built,
or "reversed". We define a name calling Name() on a route. For example:
To build a URL, get the route and call the URL() method, passing a sequence of
key/value pairs for the route variables. For the previous route, we would do:
...and the result will be a url.URL with the following path:
This also works for host and query value variables:
All variables defined in the route are required, and their values must
conform to the corresponding patterns. These requirements guarantee that a
generated URL will always match a registered route -- the only exception is
for explicitly defined "build-only" routes which never match.
Regex support also exists for matching Headers within a route. For example, we could do:
...and the route will match both requests with a Content-Type of `application/json` as well as
`application/text`
There's also a way to build only the URL host or path for a route:
use the methods URLHost() or URLPath() instead. For the previous route,
we would do:
And if you use subrouters, host and path defined separately can be built
as well:
Mux supports the addition of middlewares to a Router, which are executed in the order they are added if a match is found, including its subrouters. Middlewares are (typically) small pieces of code which take one request, do something with it, and pass it down to another middleware or the final handler. Some common use cases for middleware are request logging, header manipulation, or ResponseWriter hijacking.
Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed to it, and then calls the handler passed as parameter to the MiddlewareFunc (closures can access variables from the context where they are created).
A very basic middleware which logs the URI of the request being handled could be written as:
Middlewares can be added to a router using `Router.Use()`:
A more complex authentication middleware, which maps session token to users, could be written as:
Note: The handler chain will be stopped if your middleware doesn't call `next.ServeHTTP()` with the corresponding parameters. This can be used to abort a request if the middleware writer wants to.
14 versions
Latest release: 7 months ago
27,498 dependent packages
View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/gorilla/mux
View more repository details: https://repos.ecosyste.ms/hosts/GitHub/repositories/gorilla%2Fmux
Dependent Repos 97,463
paketo-buildpacks/dotnet-core
A Cloud Native Buildpack for .NET Core- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 134 MB - Last synced: 9 days ago - Pushed: 9 days ago
rxrddd/austin-v2
基于kratos 的聚合消息推送平台- v1.8.0 go.sum
Size: 1.77 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
cilium/cilium-olm 📦
- v1.6.2 tools/go.sum
- v1.7.1 tools/go.sum
- v1.7.2 tools/go.sum
- v1.7.3 tools/go.sum
- v1.8.0 tools/go.sum
Size: 982 KB - Last synced: 9 months ago - Pushed: 12 months ago
rancher-max/rancher Fork of rancher/rancher
Complete container management platform- v1.8.0 pkg/apis/go.sum
- v1.8.0 pkg/client/go.sum
Size: 131 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
influxdata/influxdb-observability
- v1.6.2 tests-integration/go.sum
- v1.7.3 tests-integration/go.sum
- v1.8.0 tests-integration/go.sum
Size: 2.21 MB - Last synced: 20 days ago - Pushed: 20 days ago
krakend/krakend-ratelimit
A collection of curated ratelimiter adaptors for the KrakenD framework- v1.6.1 go.sum
- v1.8.0 go.sum
Size: 111 KB - Last synced: 7 months ago - Pushed: 7 months ago
eumel8/otc-rds-operator 📦
RDS Operator for Open Telekom Cloud- v1.8.0 go.sum
Size: 359 KB - Last synced: 4 months ago - Pushed: 4 months ago
stolostron/governance-policy-template-sync Fork of open-cluster-management-io/governance-policy-template-sync 📦
- v1.8.0 go.sum
Size: 6.81 MB - Last synced: 27 days ago - Pushed: 9 months ago
TeachersPayTeachers/linux-audit-exporter
Export Linux audit status as Prometheus metrics- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 112 KB - Last synced: 3 months ago - Pushed: 3 months ago
eblindeman/dashboard Fork of kubernetes/dashboard
General-purpose web UI for Kubernetes clusters- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 152 MB - Last synced: about 1 year ago - Pushed: over 1 year ago
Zondax/rosetta-filecoin-lib
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
Size: 337 KB - Last synced: 19 days ago - Pushed: 19 days ago
jimxshaw/proglog
Go example commit log service with protobuf- v1.8.0 go.mod
- v1.8.0 go.sum
Size: 24.4 KB - Last synced: about 1 month ago - Pushed: almost 2 years ago
RafaySystems/terraform-provider-rafay
Rafay terraform provider- v1.6.2 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 4.45 MB - Last synced: 1 day ago - Pushed: 1 day ago
IBM/ibm-commonui-operator
Operator used to install the common webui service- v1.8.0 go.sum
Size: 45.5 MB - Last synced: 2 days ago - Pushed: 2 days ago
Boroda76/go_service_naked
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 791 KB - Last synced: 24 days ago - Pushed: about 1 year ago
GoogleCloudPlatform/gke-poc-toolkit
📦 Demo generator for Google Kubernetes Engine!- v1.8.0 analytics/go.mod
- v1.8.0 analytics/go.sum
Size: 12.8 MB - Last synced: 15 days ago - Pushed: 15 days ago
LATOKEN/bridge-backend-service
- v1.8.0 src/go.mod
- v1.8.0 src/go.sum
Size: 449 KB - Last synced: 4 months ago - Pushed: over 1 year ago
companieshouse/insolvency-api
- v1.7.3 go.mod
- v1.7.3 go.sum
Size: 1.04 MB - Last synced: 27 days ago - Pushed: 7 months ago
Mu-L/docker-slim Fork of slimtoolkit/slim
DockerSlim (docker-slim): Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)- v1.7.2 go.sum
- v1.8.0 go.sum
- v1.8.0 pkg/third_party/compose-go/go.sum
Size: 64.8 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
outscale/cluster-api-provider-outscale
- v1.8.0 go.sum
Size: 15.7 MB - Last synced: 6 days ago - Pushed: 6 days ago
kubeshop/kusk
CLI for Kusk Gateway related functionality- v1.8.0 go.sum
Size: 6.51 MB - Last synced: 27 days ago - Pushed: over 1 year ago
drand/drand
🎲 A Distributed Randomness Beacon Daemon - Go implementation- v1.7.4 go.mod
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
Size: 51 MB - Last synced: 1 day ago - Pushed: 2 days ago
drh-determined-ai/determined Fork of determined-ai/determined
Determined: Deep Learning Training Platform- v1.8.0 agent/go.mod
- v1.6.2 agent/go.sum
- v1.7.2 agent/go.sum
- v1.7.3 agent/go.sum
- v1.8.0 agent/go.sum
- v1.6.2 master/go.sum
- v1.7.3 master/go.sum
- v1.8.0 master/go.sum
Size: 114 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
jt-nti/fabric-builder-k8s Fork of hyperledger-labs/fabric-builder-k8s
Proof of concept Fabric builder for Kubernetes- v1.8.0 go.sum
Size: 320 KB - Last synced: 1 day ago - Pushed: 2 days ago
kubernetes-sigs/cluster-api-provider-nested
Cluster API Provider for Nested Clusters- v1.8.0 virtualcluster/pkg/vn-agent/server/test/go.sum
Size: 3.04 MB - Last synced: 3 days ago - Pushed: 23 days ago
manish8561/go_microservice
go_microservice with grpc- v1.8.0 farm/go.sum
Size: 1.38 MB - Last synced: 7 months ago - Pushed: 8 months ago
stratosnet/stratos-chain
Stratos Blockchain- v1.7.4 go.mod
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
Size: 5.26 MB - Last synced: 3 days ago - Pushed: 3 days ago
Seanstoppable/wtf Fork of wtfutil/wtf
The personal information dashboard for your terminal.- v1.6.2 go.sum
Size: 47.6 MB - Last synced: 10 months ago - Pushed: 12 months ago
bnb-chain/bnc-cosmos-sdk
- v1.7.3 go.mod
- v1.7.3 go.sum
Size: 30.4 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
sapcc/absent-metrics-operator
Absent Metrics Operator creates metric absence alerts atop Kubernetes- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 10.1 MB - Last synced: 29 days ago - Pushed: about 1 month ago
leoluz/argo-rollouts Fork of argoproj/argo-rollouts
Progressive Delivery for Kubernetes- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 25.8 MB - Last synced: 27 days ago - Pushed: about 1 year ago
stolostron/multicloud-operators-subscription-release
Managing helm release with operators for multicloud.- v1.8.0 go.mod
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 1.63 MB - Last synced: 27 days ago - Pushed: about 1 year ago
dreamer-zq/cosmos-sdk Fork of cosmos/cosmos-sdk
:chains: A Framework for Building High Value Public Blockchains :sparkles:- v1.8.0 cosmovisor/go.mod
- v1.6.2 cosmovisor/go.sum
- v1.7.3 cosmovisor/go.sum
- v1.8.0 cosmovisor/go.sum
- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 217 MB - Last synced: 27 days ago - Pushed: 7 months ago
millicent-money/cosmos-sdk
- v1.8.0 cosmovisor/go.mod
- v1.6.2 cosmovisor/go.sum
- v1.7.3 cosmovisor/go.sum
- v1.8.0 cosmovisor/go.sum
- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
- v1.6.2 store/tools/ics23/go.sum
- v1.7.3 store/tools/ics23/go.sum
- v1.8.0 store/tools/ics23/go.sum
Size: 361 MB - Last synced: 9 months ago - Pushed: about 1 year ago
berty/labs
Berty Labs is a mobile app to explore IPFS on mobile- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 3.44 MB - Last synced: 10 days ago - Pushed: about 1 year ago
celo-org/eksportisto 📦
Metric Exporter for celo-node- v1.7.4 go.mod
Size: 1.4 MB - Last synced: 4 months ago - Pushed: 8 months ago