Navigate:
~$CHI0.8%

chi: Lightweight HTTP router for Go

Composable Go HTTP router for web services with middleware chains and route groups.

LIVE RANKINGS • 09:50 AM • STEADY
TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100TOP 100
OVERALL
#82
55
BACKEND & APIS
#3
3
30 DAY RANKING TREND
ovr#82
·Backe#3
STARS
21.8K
FORKS
1.1K
7D STARS
+162
7D FORKS
+1
See Repo:
Share:

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.

chi

1

Context-Based Design

Built on Go's context package for request-scoped value passing, cancellation, and timeout handling across middleware chains.

2

Composable Architecture

Supports middleware stacking, route groups, and sub-router mounting for organizing complex routing structures. Allows inline middleware application and nested route definitions.

3

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)
}

vv5.2.5

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
vv5.2.3

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
vv5.2.2

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


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers