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
tigefa4u/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 year ago - Pushed: about 1 year ago
celo-org/eksportisto 📦
Metric Exporter for celo-node- v1.7.4 go.sum
Size: 1.4 MB - Last synced: 5 months ago - Pushed: 9 months ago
networkservicemesh/sdk-vpp
- v0.0.0-20181024020800-521ea7b17d02 go.sum
Size: 1.29 MB - Last synced: about 2 months ago - Pushed: about 2 months ago
elisasre/kops-autoscaler-openstack
Provide AutoScalingGroup capability to OpenStack Kops- v1.7.2 go.sum
- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 17.5 MB - Last synced: 13 days ago - Pushed: 14 days ago
ekmixon/istio Fork of istio/istio
Connect, secure, control, and observe services.- v1.8.0 go.mod
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 199 MB - Last synced: 4 days ago - Pushed: 4 days ago
apache/submarine
Submarine is Cloud Native Machine Learning Platform.- v1.8.0 submarine-cloud-v3/go.sum
Size: 29.3 MB - Last synced: 6 days ago - Pushed: about 2 months ago
BlackRRR/payment-emulator
- v1.8.0 go.mod
- v1.8.0 go.sum
Size: 45.9 KB - Last synced: about 1 year ago - Pushed: almost 2 years ago
moov-io/irs
Internal Revenue Service (IRS) Filing Information Returns Electronically (FIRE)- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 1.47 MB - Last synced: 13 days ago - Pushed: 13 days ago
pulumi/pulumi-kubernetes-operator
A Kubernetes Operator that automates the deployment of Pulumi Stacks- v1.6.2 go.sum
- v1.7.1 go.sum
- v1.7.2 go.sum
Size: 1.68 MB - Last synced: 13 days ago - Pushed: 13 days ago
stashed/apimachinery
Stash API types and client-go- v1.8.0 go.sum
Size: 47.2 MB - Last synced: about 2 months ago - Pushed: about 2 months ago
Blake8868/mvm Fork of MetisProtocol/mvm
A hard fork of the Optimistic Ethereum protocol (optimism.io)- v1.8.0 go/batch-submitter/go.sum
- v1.8.0 go/gas-oracle/go.sum
- v1.6.2 l2geth/go.sum
- v1.7.3 l2geth/go.sum
- v1.8.0 l2geth/go.sum
Size: 27.1 MB - Last synced: about 1 year ago - Pushed: over 1 year ago
vinted/prometheus Fork of prometheus/prometheus
The Prometheus monitoring system and time series database.- v1.6.2 documentation/examples/remote_storage/go.sum
- v1.7.2 documentation/examples/remote_storage/go.sum
- v1.7.3 documentation/examples/remote_storage/go.sum
- v1.8.0 documentation/examples/remote_storage/go.sum
- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 161 MB - Last synced: 24 days ago - Pushed: 25 days ago
choria-io/provisioner
Choria Server Provisioning System- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 4.6 MB - Last synced: 2 months ago - Pushed: 3 months ago
sigstore/rekor-monitor
Log monitor for Rekor to verify immutability and monitor entries- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 1.29 MB - Last synced: 5 days ago - Pushed: 6 days ago
mclarke47/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: 11.8 MB - Last synced: about 1 month ago - Pushed: over 1 year ago
codeboten/opentelemetry-lambda Fork of open-telemetry/opentelemetry-lambda
- v1.6.2 collector/go.sum
- v1.7.2 collector/go.sum
- v1.7.3 collector/go.sum
- v1.8.0 collector/go.sum
Size: 1.59 MB - Last synced: 8 months ago - Pushed: 8 months ago
moov-io/ach-test-harness
Programmatic and configurable ACH scenario testing of returns, NOC/corrections, reconciliation, etc.- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 973 KB - Last synced: 11 days ago - Pushed: 11 days ago
VibrentHealth/keycloak-operator Fork of keycloak/keycloak-operator
A Kubernetes Operator based on the Operator SDK for syncing resources in Keycloak- v1.6.2 go.sum
- v1.7.1 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
Size: 12.4 MB - Last synced: 3 months ago - Pushed: 3 months ago
overline-mining/gool
it's scary- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 957 KB - Last synced: 8 days ago - Pushed: 9 days ago
KiraCore/sekai
backend - blockchain application- v1.8.0 go.mod
- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 17.3 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
inhere/kite-go
Kite - Personal developer tool command application. 个人的开发者辅助工具应用- v1.8.0 go.sum
Size: 5.31 MB - Last synced: about 2 months ago - Pushed: about 2 months ago
lf-edge/edge-home-orchestration-go
Home Edge Project in LF Edge - Edge Orchestration for home edge devices to enabling smart home use cases.- v1.8.0 go.mod
Size: 5.09 MB - Last synced: 23 days ago - Pushed: 24 days ago
openshift/cluster-kube-descheduler-operator
An operator to run descheduler on OpenShift.- v1.8.0 go.sum
Size: 66.5 MB - Last synced: 4 days ago - Pushed: 5 days ago
vdavalon01/plumber Fork of streamdal/plumber
A swiss army knife CLI tool for interacting with Kafka, RabbitMQ and other messaging systems.- v1.7.4 go.sum
Size: 43.3 MB - Last synced: 10 months ago - Pushed: 10 months ago
metallb/metallb-operator
MetalLB Operator for deploying metallb- v1.8.0 go.sum
Size: 16.7 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
rogue73/hugo Fork of gohugoio/hugo
The world’s fastest framework for building websites.- v1.6.2 go.sum
- v1.7.2 go.sum
- v1.7.3 go.sum
- v1.8.0 go.sum
Size: 109 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
kare/ewallet
Go program that generates Ethereum private key, public key and address- v1.8.0 go.sum
Size: 85 KB - Last synced: about 1 month ago - Pushed: 5 months ago
cloudfoundry/app-autoscaler-release
Automated scaling for apps running on Cloud Foundry- v1.8.0 src/autoscaler/go.mod
- v1.8.0 src/autoscaler/go.sum
Size: 67.4 MB - Last synced: about 1 month ago - Pushed: about 1 month ago
BrianPHChen/tendermint_isl
- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 65 MB - Last synced: about 1 year ago - Pushed: over 1 year ago
datalayer-externals/flux Fork of fluxcd/flux2
Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.- v1.8.0 go.mod
- v1.8.0 go.sum
Size: 7.18 MB - Last synced: 20 days ago - Pushed: 21 days ago
create-go-app/net_http-go-template
📝 net/http backend template for Create Go App CLI.- v1.8.0 go.mod
- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 423 KB - Last synced: 26 days ago - Pushed: 27 days ago
pickkaa/berty Fork of berty/berty
Berty is a secure peer-to-peer messaging app that works with or without internet access, cellular data or trust in the network- v1.6.2 go.sum
- v1.7.3 go.sum
- v1.6.2 tool/go.sum
- v1.7.3 tool/go.sum
Size: 84.2 MB - Last synced: 23 days ago - Pushed: about 1 year ago
zaibon/go-ipfs Fork of ipfs/kubo
IPFS implementation in Go- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 40.8 MB - Last synced: about 1 year ago - Pushed: over 1 year ago
meonBot/go-ipfs Fork of devcode1981/go-ipfs
IPFS implementation in Go- v1.6.2 go.sum
- v1.7.3 go.sum
Size: 40.8 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
akram/origin Fork of openshift/origin
Enterprise Kubernetes for Developers- v1.7.4 go.sum
- v1.8.0 go.sum
Size: 1.16 GB - Last synced: 8 days ago - Pushed: 9 days ago
sknot-rh/kubernetes-client Fork of fabric8io/kubernetes-client
Java client for Kubernetes & OpenShift- v1.6.2 extensions/camel-k/generator-v1/go.sum
- v1.7.1 extensions/camel-k/generator-v1/go.sum
Size: 442 MB - Last synced: about 1 year ago - Pushed: over 1 year ago