chi is a small Go router for building REST APIs and HTTP services. It stays compatible with net/http and stdlib middleware.
Overview
chi is a Go package that routes HTTP requests using a lightweight radix trie design. It targets teams that want maintainable REST APIs without leaving the standard library handler model.
Routing accepts URL patterns with named parameters and wildcards, mounts sub-routers, and groups routes with inline or shared middleware. Handlers remain ordinary net/http types, so third-party middleware from the wider Go ecosystem can plug in directly.
The router builds on Go’s context package for per-request values, cancellation, and timeouts. Optional companion packages add common middleware such as logging, compression, throttling, request IDs, recovery, and several safe client IP extractors, plus helpers for rendering and route documentation generation.
The core router is compact and ships without external dependencies beyond the stdlib. Documentation can be generated from source into JSON or Markdown to describe mounted routes.
Key features
- net/http compatible handler model
- Named params and wildcard routes
- Route groups and sub-router mounts
- Optional chi/middleware suite
- Context values and timeouts
- Doc generation for routes
- Modular render helpers
- No third-party dependencies
Use cases
- Building Go REST API servers
- Composing HTTP middleware chains
- Mounting versioned API sub-routers
- Publishing auto-generated route docs
- Microservice HTTP entrypoints