A Go mux and middleware package that provides statically typed contexts and fast, scalable routing.
gocraft/web is a Go router and middleware package for building web applications. It provides a fast, tree-based router with O(log(N)) routing performance and emphasizes type safety through custom contexts, allowing developers to pass strongly typed data between middleware and handlers.
Go developers building web applications who need a performant, type-safe router with flexible middleware composition and nested routing capabilities.
Developers choose gocraft/web for its combination of high performance (adding as little as 3-10μs latency), static typing via custom contexts, and a clean API that integrates seamlessly with Go's standard net/http package.
Go Router + Middleware. Your Contexts.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show added latency of only 3-10μs per request with O(log(N)) routing scalability, as tracked in BENCHMARK_RESULTS, ensuring low overhead for high-traffic apps.
Enables passing strongly typed data between middleware and handlers using custom structs, improving code safety and reducing runtime errors compared to dynamic maps.
Supports hierarchical routing with different contexts and middleware for distinct app sections, like admin areas or APIs, allowing clean separation of concerns.
Works directly with Go's standard http package, including http.ResponseWriter and http.Request, making it easy to integrate into existing Go ecosystems.
Does not support optional path segments or regexps outside segments, requiring multiple route definitions for variations, as admitted in the README.
Ships with only basic middleware (logger, error show, static files), forcing reliance on community contributions or custom code for advanced features like JSON binding.
Nested routers require careful embedding of parent contexts in structs, which can lead to boilerplate and increased cognitive load for setup and maintenance.