Gorilla Mux

Gorilla Mux

github.com

1

About this website

Gorilla Mux is a powerful HTTP router and URL matcher for Go, developed by the Gorilla Web Toolkit project (originally maintained by Kamil Kisiel and later by the community). It is one of the most widely-used HTTP routing libraries in the Go ecosystem, providing a rich set of features for building RESTful APIs and web applications. Unlike the standard library net/http ServeMux, which only supports simple prefix-based matching, Gorilla Mux supports sophisticated URL pattern matching with regular expressions, path variables, HTTP method restrictions, host matching, and custom matchers. Key features include: URL path matching with named variables and regular expressions (e.g., /articles/{id:[0-9]+} matches only numeric article IDs), HTTP method-based routing (restricting routes to GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, or custom methods), host-based routing (matching different routers for different subdomains or domain names), query parameter matching (routes can require specific query parameters to be present), scheme matching (restricting routes to HTTP or HTTPS), custom matcher functions (user-defined matching logic for complex routing rules), URL building and reversing (generating URLs from route names and parameters, ensuring that generated URLs always match the defined route patterns), middleware support via sub-routers (a router can be mounted as a sub-router under another router with its own middleware chain), trailing slash normalization (automatically redirecting or matching paths with or without trailing slashes), strict or non-strict slash matching (configurable per router), route walking (iterating over all registered routes, useful for documentation generation and testing), and graceful HTTP server shutdown integration. After the original Gorilla Toolkit project was archived in 2022, the community maintained a fork that continues active development. As of 2026, Gorilla Mux has over 21,000 stars.

Tags & Categories

Categories

Tags

Statistics

1
Views
0
Clicks
0
Like
0
Dislike

Comments

Log In to post a comment

No comments yet. Be the first!