// the find
fasthttp/router
Router implementation for fasthttp
A radix-tree router for fasthttp, based on julienschmidt/httprouter, with named, optional, regex-constrained and catch-all path parameters. It suits Go services already committed to fasthttp that want predictable, cheap routing. If your stack is net/http, this is the wrong package.
- Matching is exact: a request resolves to one handler or none, so there are no registration-order or longest-match rules to work out. Trailing-slash redirects are on by default and can be turned off.
- One radix tree per HTTP method, with children ordered by how many routes sit beneath them, so common prefixes are shared and the busiest branches are tried first. The README claims zero allocations on static paths and only the parameter slice on parameterised ones.
- The radix package is split out with its own node, tree and utils tests, every top-level source file has a matching _test.go, and a test workflow is checked in.
- The last push was 2025-01-01, about twenty-one months before this review. For a routing dependency, that raises the question of whether fasthttp changes and newer Go releases are being picked up.
- The speed claims are the weakest part of the README. 'Faster than httprouter itself' rests on a third-party benchmark image with no version, hardware, or command to reproduce it. Benchmark your own route table before adopting it on that basis.
- It is bound to fasthttp.RequestHandler, so it cannot be mounted on net/http, and middleware has to be written against fasthttp's context. The README also says HandleMethodNotAllowed 'might be required' to be false 'to avoid problems' without saying which problems.
- Parameters come back from ctx.UserValue as interface{} under string keys. A misspelled name in a handler returns nil, and nothing in the README suggests the router catches that at registration time.