chi: Lightweight HTTP router for Go
Composable Go HTTP router for web services with middleware chains and route groups.
Learn more about chi
chi is an HTTP router library for Go that provides routing functionality for web services and REST APIs. The router is implemented using a Patricia Radix trie data structure and is fully compatible with Go's standard net/http package. chi is built around Go's context package for handling request-scoped values, timeouts, and cancellations across handler chains. The library focuses on composability through middleware stacking, route grouping, and sub-router mounting for organizing large API services.
Context-Based Design
Built on Go's context package for request-scoped value passing, cancellation, and timeout handling across middleware chains.
Composable Architecture
Supports middleware stacking, route groups, and sub-router mounting for organizing complex routing structures. Allows inline middleware application and nested route definitions.
Standard Library Compatible
Fully compatible with net/http handlers and middleware, requiring no external dependencies beyond Go's standard library.
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
func main() {
r := chi.NewRouter()
r.Use(middleware.Logger)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("welcome"))
})
http.ListenAndServe(":3000", r)
}Bump minimum Go to 1.22 and use new features
- –Bump minimum Go to 1.22 and use new features
- –Refactor graceful shutdown example
- –Refactor to use atomic type
- –update reverseMethodMap in RegisterMethod
- –Update comment about min Go version
Add pathvalue example to README and implement PathValue handler.
- –Add pathvalue example to README and implement PathValue handler
- –Allow multiple whitespace between method & pattern
- –Avoid potential nil dereference
- –feat(mux): support http.Request.Pattern in Go 1.23
- –Fix flaky Throttle middleware test by synchronizing token usage
Fixes a lower-severity Open Redirect vulnerability and includes various code improvements and optimizations.
- –Use strings.Cut in a few places
- –Fix non-constant format strings in t.Fatalf
- –Apply fieldalignment fixes to optimize struct memory layout
- –go 1.24
- –chore: delint ioutil usage
Top in Backend & APIs
Related Repositories
Discover similar tools and frameworks used by developers
redis-py
High-performance Python Redis client with clustering, pipelines, and async operation support.
Dapper
Lightweight ORM extending ADO.NET with simple query methods for .NET applications.
Discourse
Self-hostable forum platform with Ruby on Rails, real-time chat, and plugin support.
Express
Middleware-based HTTP routing and response handling for Node.js.
Node.js
JavaScript runtime built on V8 for server-side development.
Related Reading
Guides and comparisons from the Greptile content library
Greptile Ranks #1 on Martian's AI Code Review Benchmark
Greptile ranks #1 on Martian's independent online AI code review benchmark, leading all evaluated tools in F1 score and precision with near-leading recall.
How to Evaluate Code Review Tools: The 4 Step Framework
A 4-step framework for evaluating code review tools on large teams with complex codebases: define what you need, build a shortlist, run a live test, and get developer feedback. Plus a shortlist of tools and how to future-proof your review process.
Flaky Tests: What Is a Flaky Test and How Do You Manage Them?
What flaky tests are, what causes them, how to detect them, and 12 ways to fix them. Plus why end-to-end tests are more prone to flakiness, and how seeing what actually happened during a run helps you tell a test problem from a code problem.
27 Code Quality Tools that Catch Bugs [2026 Review]
The best code quality tools that catch bugs, security vulnerabilities, and runtime errors, sorted by language, with type, noise level, cost, and who each one is for.