MuxMaster

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+.

Highlights

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.

Fastest stdlib-compatible router

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.

100% net/http compatible

Handlers stay http.Handler; middleware stays func(http.Handler) http.Handler. Adopt incrementally — your existing handlers compile unchanged.

Typed errors and parameters

Optional HandlerFuncE threads errors through middleware. Params.Int, Params.Bool, Params.UUID parse and validate path parameters in one call.

Production-grade middleware

RequestID, Recoverer, Logger, Compress, RealIP, Timeout, Throttle, BasicAuth, JWTAuth, OAuth2Introspect, APIKey, CORS — all hardened and audited.

Dogfooded — this site runs on MuxMaster

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.

Performance

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.

Per route category — v1.0.1 vs v1.1.0 default vs v1.1.0 Pooled

Case v1.0.1 v1.1.0 default v1.1.0 Pooled
Static route27 ns / 0 B25.1 ns / 0 B25.1 ns / 0 B
1-parameter route110 ns / 416 B / 1 alloc105 ns / 384 B / 1 alloc49.6 ns / 0 B / 0 allocs
2-parameter route124 ns / 448 B / 1 alloc119 ns / 416 B / 1 alloc55.9 ns / 0 B / 0 allocs
3-parameter route138 ns / 480 B / 1 alloc135 ns / 480 B / 1 alloc58.6 ns / 0 B / 0 allocs
Catch-all112 ns / 384 B / 1 alloc108 ns / 384 B / 1 alloc43.9 ns / 0 B / 0 allocs
Parallel 1-parameter route105 ns / 384 B / 1 alloc100 ns / 384 B / 1 alloc6.3 ns / 0 B / 0 allocs
Fast 1-parameter route51 ns / 32 B / 1 alloc50.3 ns / 32 B / 1 allocn/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.

Versus every other Go HTTP router (1-parameter route)

Router ns/op B/op allocs/op
MuxMaster Pooled (Opt O13)4500
MuxMaster Fast50321
MuxMaster default1083841
httprouter56641
Fiber v3 (fasthttp)21200
bunrouter1831923
chi v53543044
gorilla/mux3 444 278n/a156 015

MuxMaster is the fastest Go HTTP router across every route category measured. Full per-category report at 2026-05-12 competitor showdown.

A quick look

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.

Frequently asked questions

What is MuxMaster?

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.

What Go version does MuxMaster require?

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.

Is MuxMaster compatible with 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.

How fast is MuxMaster?

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.

What is the catch with 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.

What is MuxMaster's license?

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.

How does MuxMaster compare to chi, gin, gorilla/mux, and httprouter?

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.