Build REST APIs in Go with clean, organized URL routing and grouped endpoints.
Add middleware like logging, timeouts, and authentication to specific routes or entire route groups.
Create admin sections and sub-routers for different parts of your application.
Generate routing documentation automatically from your code structure.
Chi is a lightweight router for building web APIs and HTTP services in the Go programming language. A router is the part of a web server that decides which function handles which web address, for example, sending requests for "/articles" to one handler and "/users" to another. Chi solves the problem of organizing these routes cleanly as a project grows larger and more complex. The core idea behind chi is composability, meaning you build your API by stacking small, reusable pieces together. These pieces are called middlewares (pronounced "middle-wear"), and they are functions that run before or after your main handler, handling things like logging requests, setting timeouts, or checking if someone is allowed to access a page. Chi lets you attach these middlewares to the entire app, to a group of related routes, or to a single endpoint individually. Under the hood, chi uses a data structure called a Patricia Radix trie to match incoming URLs to the right handler quickly. Despite this technical underpinning, chi works entirely with Go's built-in standard library, there are no external dependencies, which keeps it small (less than 1,000 lines of code) and fully compatible with any existing Go HTTP tools. You would use chi when you are building a REST API in Go and want clean URL routing, grouped routes (like all /articles/* endpoints together), sub-routers for sections like /admin, and middleware support, without pulling in a large external framework. It also includes optional tools for auto-generating routing documentation from your code. The full README is longer than what was provided.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.