chi: A lightweight, idiomatic and composable router for building Go HTTP services.
What problem it solves
Large REST API services need routing structures that remain maintainable as projects grow and change. Go HTTP services also need middleware, request-scoped values, cancellation, and timeouts to work naturally with standard `net/http` handlers.
Key features
Standard net/http compatibility — The router works with standard `net/http` request handlers and middleware, allowing existing compatible packages to be reused.
Source: README
Composable API organization — Applications can organize routes with middleware, inline middleware, route groups, and mounted sub-routers.
Source: README, mux.go
Request context control — Request contexts carry scoped values and support cancellation and timeout signaling across a handler chain.
Source: README
Routing patterns and parameters — Routes support named parameters and wildcards, with values available to handlers and middleware through the request context.
Source: README
Optional middleware package — An optional `middleware` package includes standard handlers for concerns such as logging, recovery, request IDs, timeouts, throttling, authentication, and client IP handling.
Source: README, middleware
Quick start
Copied verbatim from the project's README.
go get -u github.com/go-chi/chi/v5package 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)
}Who it may suit
This may suit Go developers building HTTP services that use `net/http`, particularly maintainable REST APIs organized around middleware and composable routes.
Topics to discuss
Which routing and middleware patterns are most useful in large Go HTTP services?
How should optional packages be organized as service requirements evolve?
What examples would help newcomers understand context-aware routing?
Written by ReadmeX AI from the project's README, source and public GitHub data; it may contain mistakes.
Read the original README https://github.com/go-chi/chi#readme
ReadmeX opened this community for a trending project; it is not run by the project. Maintainers can claim it from the community page.
Comments
…