A high-speed, flexible tree-based HTTP router for Go with relaxed routing rules and wildcard support.
httptreemux is a tree-based HTTP router for Go designed for high-speed routing with flexible pattern matching. It solves the need for efficient URL routing in web applications by allowing overlapping wildcard and static routes, making it easier to design complex routing logic without sacrificing performance.
Go developers building web servers or APIs that require fast and flexible URL routing, especially those who need overlapping route patterns or efficient tree-based matching.
Developers choose httptreemux for its relaxed routing rules, which allow a path segment to be a wildcard in one route and static in another, combined with near-httprouter performance and built-in concurrency safety for route management.
High-speed, flexible tree-based HTTP router for Go.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows overlapping wildcards and static tokens in different routes, enabling complex URL designs without conflicts, as shown in the routing rules examples.
Uses a patricia tree for high-speed URL routing, inspired by httprouter, with performance close to it in benchmarks.
Supports creating clusters of routes with shared prefixes via NewGroup, making API versioning or path management cleaner.
Compatible with Go's context package and http.HandlerFunc through UsingContext or NewContextMux, facilitating modern middleware integration.
Includes an RWMutex for safe route addition from multiple goroutines when SafeAddRoutesWhileRunning is enabled, as detailed in the concurrency section.
The README warns that the project is not maintained, risking unpatched bugs and lack of updates for new Go versions or features.
Benchmarks indicate it's close to but slower than httprouter, making it less ideal for edge cases where every nanosecond counts.
Light on features; lacks built-in middleware and has unexpected differences, such as no automatic query string modification like gorilla/pat.
Requires careful configuration with PathSource and EscapeAddedRoutes to properly handle URLs with escaped characters, adding setup complexity.