Build a REST API that routes requests to different handlers based on URL path, HTTP method, and domain.
Create a multi-tenant web application where different subdomains route to different subrouters.
Add middleware to log requests, check authentication, or modify responses across multiple routes.
Serve a single-page application with dynamic URL patterns that extract IDs or categories from the path.
Gorilla mux is a routing library for Go web servers. When you build a web server, you need a way to decide which function handles each incoming URL, for example, requests to /products go to one function and requests to /articles go to another. Go's standard library includes a basic router called http.ServeMux, and gorilla mux is a more powerful alternative that plugs into the same interface; the name mux is short for HTTP request multiplexer. The library lets you define URL patterns that include variable placeholders. A route like /articles/{category}/{id} captures the category and id from the URL and makes them available inside the handler. Routes can also be restricted by HTTP method, by domain or subdomain, by URL scheme, by header values, by query parameters, or by a custom matching function you write yourself. Multiple conditions can be combined on a single route, and routes are tested in the order they were added so the first match wins. A feature called subrouting lets you group routes that share common conditions, such as all routes for a particular subdomain or under a path prefix. The parent condition is tested first, and inner routes are only checked when it matches, convenient for organization and slightly faster. Registered URLs can also be reversed, meaning you ask the router to generate a URL for a named route, which keeps links inside the application correct as routes change. Because gorilla mux satisfies Go's standard http.Handler interface, it plugs into existing Go HTTP code without special setup. It supports middleware, serving static files, and serving single-page applications alongside an API. The full README is longer than what was provided.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.