Lightweight, composable HTTP router for Go services built on net/http
open sourceMITfree
chi is a small router for building HTTP services in Go, made for large REST APIs that stay maintainable as they grow. It is fully compatible with net/http, so any standard handler or middleware works with it, and it is built on the context package for request-scoped values, cancellation and timeouts. The core router is about 1,000 lines with no dependencies outside the standard library; optional packages add middleware, response rendering and route documentation generation.
Problems it solves
- route HTTP requests in a Go REST API without a heavy framework
- organise a growing Go API into route groups and sub-routers
- add middleware to Go handlers that stays compatible with net/http
Features
- Route groups, inline middleware and mounting sub-routers
- Works with any net/http handler or middleware
- Request context for values, cancellation and timeouts
- Optional middleware package (logging, request IDs, recovery and more)
- docgen generates routing docs as JSON or Markdown
- No dependencies beyond the Go standard library
Alternatives
The same job
These do what chi does.
- Gin The fastest full-featured HTTP web framework for Go
- go-restful Lean Go package for building REST-style web services
- Echo High performance, minimalist Go web framework
- Fiber Express inspired web framework written in Go
- go-zero A cloud-native Go microservices framework with a code generation CLI
- Iris Web framework for Go whose builder makes out-of-order setup a compile error
