mux
by
gorilla

Description: Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍

View on GitHub ↗

Summary Information

Updated 39 minutes ago
Added to GitGenius on April 8th, 2021
Created on October 2nd, 2012
Open Issues & Pull Requests: 37 (+0)
Number of forks: 1,885
Total Stargazers: 21,836 (-1)
Total Subscribers: 297 (-1)

Issue Activity (beta)

Open issues: 24
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 903 days
Stale 30+ days: 24
Stale 90+ days: 21

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • question (141)
  • stale (96)
  • bug (88)
  • enhancement (32)
  • help wanted (23)
  • documentation (21)
  • wontfix (11)
  • proposal (3)

Most active issues this week

No issue events were indexed in the last 7 days.

Repository Insights (GitGenius)

Median issue/PR response: 1.8 hours
Mean response time: 457.2 days
90th percentile: 1899.4 days
Tracked items: 26

Most active contributors

Detailed Description

Gorilla/mux is a powerful HTTP router and URL matcher for Go web servers that implements the http.Handler interface, making it compatible with Go's standard http.ServeMux. The package provides a request router and dispatcher that matches incoming HTTP requests against registered routes and calls the appropriate handler. The name mux stands for HTTP request multiplexer, and it serves as a core component for building RESTful APIs and web applications in Go.

The router supports matching requests based on multiple criteria including URL host, path, path prefix, schemes, header values, query values, and HTTP methods. Routes can also use custom matcher functions for more complex matching logic. URL variables can be defined using the format {name} or {name:pattern}, where pattern is an optional regular expression. This allows developers to extract parameters from URLs and access them through the mux.Vars() function. The router also supports regex matching for headers, enabling content-type based routing and similar use cases.

One of the standout features is the ability to build or reverse registered URLs, which helps maintain references to resources throughout an application. Routes can be named, and their URLs can be reconstructed by passing key-value pairs for route variables. The router also provides methods like URLHost() and URLPath() for building specific components of URLs, and GetVarNames() to discover required variables for a given route.

Subrouting is another powerful capability that allows developers to group routes sharing common conditions like a host, path prefix, or other attributes. Nested routes are only tested if the parent route matches, which optimizes request matching and enables the creation of domain or path namespaces. This feature is particularly useful for organizing complex applications with multiple logical sections.

The package includes middleware support through the standard MiddlewareFunc type, allowing developers to add request logging, header manipulation, response writer hijacking, and authentication. Middlewares are executed in the order they are added if a match is found, including subrouters. The router also provides CORSMethodMiddleware to simplify setting the Access-Control-Allow-Methods response header for CORS requests.

Additional features include a Walk function for visiting all registered routes, support for graceful shutdown of HTTP servers, and straightforward testing capabilities. The router can serve static files using PathPrefix() and can serve single-page applications alongside API endpoints.

According to GitGenius activity tracking, the repository has a median issue and pull request response latency of 1.8 hours across 26 tracked items, though the mean is significantly higher at 10973.3 hours, indicating some older items with delayed responses. The most active issue labels are bug with 12 occurrences, followed by stale and help wanted with 2 each. Key contributors tracked by GitGenius include jaitaiwan and jub0bs with 7 events each, and crisscross82 with 5 events. The repository shares overlapping contributors with major projects including microsoft/vscode, microsoft/typescript, and golang/go, indicating its importance in the Go ecosystem.

mux
by
gorillagorilla/mux

Repository Details

Fetching additional details & charts...