Repolode
go-chi

go-chi/chi

A lightweight, net/http-compatible router for building REST API services in Go, with middleware, route groups and sub-router mounting.

Stars
22,981
Forks
3,717
Open issues
132
Last commit
4 days ago

What is it?

chi is a router for Go HTTP services. It maps URL patterns with named parameters and wildcards to handlers, and it is built on the standard library's net/http and context packages, so any handler or middleware written for net/http can be used with it. The core router is small and has no external dependencies.

The router supports composable middleware, inline middleware on individual routes, route groups, and mounting separate sub-routers at a path prefix. This makes it practical to split a large REST API into smaller packages with their own middleware stacks. Request-scoped values, cancellation and timeouts flow through the request context.

The optional middleware package provides components such as request IDs, logging, panic recovery, compression, throttling, timeouts, and client IP detection. Companion packages cover CORS, JWT auth, rate limiting, and route documentation generation through docgen.

Key features

  • 01Named URL parameters, regexp parameters and wildcards in route patterns
  • 02Middleware stacks, inline middleware and route groups
  • 03Sub-router mounting at path prefixes
  • 04Fully compatible with standard net/http handlers and middleware
  • 05Built-in middleware package for logging, recovery, compression, timeouts and more

Use cases

  • Building large maintainable REST API services in Go
  • Splitting a monolithic HTTP service into modular sub-routers
  • Adding a standard middleware stack for logging, auth and timeouts to Go services

Quick start

  1. 1

    Install chi with go get

    go get -u github.com/go-chi/chi/v5

Topics

FAQ

What is chi?
A lightweight, net/http-compatible router for building REST API services in Go, with middleware, route groups and sub-router mounting. chi is a router for Go HTTP services. It maps URL patterns with named parameters and wildcards to handlers, and it is built on the standard library's net/http and context packages, so any handler or middleware written for net/http can be used with it. The core router is small and has no external dependencies.
Is chi free to use? What license does it have?
chi is open source under the MIT license. Check the license terms before using it in commercial products.
Is chi still maintained?
Actively maintained. The last commit to chi was on Oct 18, 2026.
What can I use chi for?
Building large maintainable REST API services in Go Splitting a monolithic HTTP service into modular sub-routers Adding a standard middleware stack for logging, auth and timeouts to Go services
How do I install chi?
Install chi with go get: go get -u github.com/go-chi/chi/v5
Where can I get chi?
The source code and installation instructions are on GitHub: https://github.com/go-chi/chi

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects