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.