
Go Chi Has a Free API — Lightweight Router for Production Go Services
Chi is a lightweight, composable router for Go HTTP services. It's 100% compatible with net/http , has zero dependencies, and powers some of the largest Go services in production. Why Chi? Zero dependencies — only uses stdlib net/http compatible — all http.Handler middleware works URL parameters — /users/{id} with type-safe extraction Middleware stack — composable, chainable middleware Quick Start go get github.com/go-chi/chi/v5 package main import ( "encoding/json" "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 . Use ( middleware . Recoverer ) r . Get ( "/" , func ( w http . ResponseWriter , r * http . Request ) { w . Write ([] byte ( "Hello, Chi!" )) }) http . ListenAndServe ( ":3000" , r ) } RESTful Routes type User struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` } func main () { r := chi . NewRouter () r . Route ( "/api/users" , func ( r chi .
Continue reading on Dev.to Webdev
Opens in a new tab

