finds.dev← search

// the find

julienschmidt/httprouter

★ 17,136 · Go · BSD-3-Clause · updated Jul 2024

A high performance HTTP request router that scales well

httprouter is a radix-tree based HTTP router for Go that trades flexibility for speed. It's the router under the hood of Gin and a dozen other frameworks, so if you've used Go web development, you've probably already relied on it indirectly. For people building their own lightweight HTTP layer without a full framework, this is the obvious starting point.

The radix tree implementation is genuinely fast — benchmarks consistently put it ahead of alternatives, and the zero-allocation path for parameterless routes is a real design win. The constraint that routes must be explicit (no ambiguous pattern overlap) forces API designers to be deliberate, which usually produces cleaner route structures. Built-in 405 Method Not Allowed and automatic OPTIONS handling saves boilerplate. The codebase is tiny — five files, easy to read and audit.

The custom handler signature `func(w, r, Params)` means any middleware written for the standard `http.Handler` interface needs an adapter shim, which creates friction when mixing third-party middleware. No route groups or subrouters — organizing a large API means manually prefixing every path string, or reaching for a wrapper library. The project has been essentially unmaintained since 2023 with open issues and PRs sitting unreviewed; Go 1.22's improved built-in `net/http` ServeMux (with method and wildcard support) now covers most of the original motivation for this router, so the delta has narrowed considerably.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →