About this project

chi is a lightweight, idiomatic and composable router for building Go HTTP services, particularly suited for large REST API projects that need to remain maintainable as they grow. Key design principles include project structure clarity, maintainability, use of standard net/http handlers, developer productivity, and the ability to decompose complex systems into smaller modular parts. The core router is under 1000 lines of code and has zero external dependencies beyond the Go standard library. It is built on Go's context package (available since Go 1.7) for request-scoped values, cancellation signaling, and timeouts across handler chains. Routing supports named URL parameters (e.g., `/users/{userID}`), wildcards (`/admin/*`), regular expression parameters, route groups, subrouters, and middleware stacking. The router uses a Patricia radix trie internally. A comprehensive optional middleware package (`github.com/go-chi/chi/v5/middleware`) provides request ID injection, logging, recovery from panics, timeout handling, client IP detection, rate throttling, compression, basic auth, content-type enforcement, cache prevention, pprof integration, and more. Any standard net/http middleware is also compatible. Related packages in the chi ecosystem include cors, docgen (automatic route documentation), jwtauth (JWT authentication), hostrouter (domain-based routing), httplog, httprate, httptracer, httpvcr, and stampede (HTTP request coalescing). The project is used in production by Pressly, Cloudflare, Heroku, 99Designs, and others. v5 added go.mod module path support.