Zero dependencies
The router and the 17 bundled middlewares are implemented on the Go standard library alone. go.mod declares no require beyond the test fixtures.
A radix-tree HTTP router for Go. Zero dependencies, O(k) lookups.
MuxMaster routes 25 ns on static paths and, with the opt-in PoolRequestBundle, 45 ns / 0 allocs on a single parameter (AMD Ryzen 9 5900HX, Go 1.26.2). It is 20 % faster than httprouter and the only stdlib-compatible router that achieves zero allocations on parameterised routes. 100 % compatible with the net/http handler interface.
Released as v1.1.0 · MIT-licensed · Requires Go 1.26+.
The router and the 17 bundled middlewares are implemented on the Go standard library alone. go.mod declares no require beyond the test fixtures.
Static-route lookups are 25 ns / 0 allocs; one-parameter routes are 45 ns / 0 allocs with the opt-in PoolRequestBundle. See the performance tables and the full benchmarks.
net/http compatibleHandlers stay http.Handler; middleware stays func(http.Handler) http.Handler. Adopt incrementally — your existing handlers compile unchanged.
Optional HandlerFuncE threads errors through middleware. Params.Int, Params.Bool, Params.UUID parse and validate path parameters in one call.
RequestID, Recoverer, Logger, Compress, RealIP, Timeout, Throttle, BasicAuth, JWTAuth, OAuth2Introspect, APIKey, CORS — all hardened and audited.
Every page you read here is served by a Go binary using MuxMaster as its router, with the bundled middleware for logging, compression, request IDs, and security headers. The router is the documentation and the proof.
Benchmarks measured on AMD Ryzen 9 5900HX, Go 1.26.2. Each row is consolidated from 10 × 2 s runs via benchstat. Methodology and per-sprint history archived in the upstream perf-audit report.
Two MuxMaster Pooled numbers appear on this page. The per-route table reports 49.6 ns (bench_test.go, the internal micro-benchmark across all seven route categories). The competitor table reports 45 ns (competitor/bench_test.go, the apples-to-apples harness registering the same route set on every router). Use 45 ns when comparing MuxMaster against other routers; use 49.6 ns when comparing across MuxMaster route categories.
| Case | v1.0.1 | v1.1.0 default | v1.1.0 Pooled |
|---|---|---|---|
| Static route | 27 ns / 0 B | 25.1 ns / 0 B | 25.1 ns / 0 B |
| 1-parameter route | 110 ns / 416 B / 1 alloc | 105 ns / 384 B / 1 alloc | 49.6 ns / 0 B / 0 allocs |
| 2-parameter route | 124 ns / 448 B / 1 alloc | 119 ns / 416 B / 1 alloc | 55.9 ns / 0 B / 0 allocs |
| 3-parameter route | 138 ns / 480 B / 1 alloc | 135 ns / 480 B / 1 alloc | 58.6 ns / 0 B / 0 allocs |
| Catch-all | 112 ns / 384 B / 1 alloc | 108 ns / 384 B / 1 alloc | 43.9 ns / 0 B / 0 allocs |
| Parallel 1-parameter route | 105 ns / 384 B / 1 alloc | 100 ns / 384 B / 1 alloc | 6.3 ns / 0 B / 0 allocs |
| Fast 1-parameter route | 51 ns / 32 B / 1 alloc | 50.3 ns / 32 B / 1 alloc | n/a |
The Pooled column requires the opt-in mux.PoolRequestBundle = true. Lifetime contract: handlers must not retain *http.Request past return. Full guide at /docs/max-performance.
| Router | ns/op | B/op | allocs/op |
|---|---|---|---|
| MuxMaster Pooled (Opt O13) | 45 | 0 | 0 |
| MuxMaster Fast | 50 | 32 | 1 |
| MuxMaster default | 108 | 384 | 1 |
httprouter | 56 | 64 | 1 |
Fiber v3 (fasthttp) | 212 | 0 | 0 |
bunrouter | 183 | 192 | 3 |
chi v5 | 354 | 304 | 4 |
gorilla/mux | 3 444 278 | n/a | 156 015 |
MuxMaster is the fastest Go HTTP router across every route category measured. Full per-category report at 2026-05-12 competitor showdown.
package main
import (
"log"
"net/http"
"github.com/FlavioCFOliveira/MuxMaster"
)
func main() {
mux := muxmaster.New()
mux.GET("/users/:id", func(w http.ResponseWriter, r *http.Request) {
id, err := muxmaster.ParamsFromContext(r.Context()).Int("id")
if err != nil {
http.Error(w, "invalid id", http.StatusBadRequest)
return
}
if err := muxmaster.JSON(w, http.StatusOK, map[string]int{"id": id}); err != nil {
log.Printf("write response: %v", err)
}
})
if err := http.ListenAndServe(":8080", mux); err != nil {
log.Fatal(err)
}
}
Read Getting started for the full walkthrough, or jump to the API reference.
MuxMaster is a high-performance, zero-dependency HTTP router for Go. It implements a radix tree with O(k) lookups, allocates zero bytes on the static-route hot path, and is fully compatible with the net/http Handler interface so existing handlers compile unchanged.
Go 1.26 or later. The minimum is set by the go directive in the upstream go.mod; see Compatibility for the full version policy.
net/http?100%. Handlers remain http.Handler and middleware remains func(http.Handler) http.Handler. A *muxmaster.Mux is a drop-in replacement for http.ServeMux everywhere the standard library accepts an http.Handler, so adoption is incremental: a single route, a single sub-tree, or a whole service.
Static-route lookups complete in 25 ns with zero allocations. One-parameter routes complete in 49.6 ns with zero allocations when the opt-in mux.PoolRequestBundle = true is enabled, or 105 ns / 1 alloc on the default path. Numbers measured on AMD Ryzen 9 5900HX, Go 1.26.2; the competitive 1-parameter measurement (45 ns, +20 % over httprouter) is reproduced from the upstream competitor showdown. See the performance tables above and Benchmarks for the full data and reproduce instructions.
PoolRequestBundle?PoolRequestBundle recycles the per-request bundle via tiered sync.Pools. The contract is strict: handlers must not retain *http.Request past return — for instance, never capture r in a goroutine that outlives the handler. The full contract, the failure modes, and the only safe goroutine pattern (drain before spawn) are documented in /docs/max-performance.
MIT. The full text is in the upstream repository at LICENSE. MIT permits commercial use, modification, distribution, and private use; the only requirement is preserving the copyright notice.
MuxMaster keeps the net/http handler signature (unlike gin, which introduces a gin.Context) and ships zero external dependencies. On a 1-parameter route it is 20 % faster than httprouter at the same handler signature MuxMaster preserves; 7.9 × faster than chi v5; 76 000 × faster than gorilla/mux. See the competitor table above and the migration guide for side-by-side equivalents.