go-chi
path: full-stack/go-chi-server/go-chi.md.md
- **fileName**: go-chi.md
- **Created on**: 2024-09-16 14:23:54
Tip
! > let's talk about go chi it's a light wight server for go lang and have some
packages like middleware and rendar
Features
-
Lightweight - cloc'd in ~1000 LOC for the chi router
Fast - yes, see benchmarks -
100% compatible with net/http - use any http or middleware pkg in the
ecosystem that is also compatible with net/http -
Designe, for modular/composable APIs - middlewares, inline middlewares,
route groups and sub-router mounting -
Context control - built on new context package, providing value chaining,
cancellations and timeouts -
Robust - in production at Pressly, CloudFlare, Heroku, 99Designs,
and many others (see discussion) -
No external dependencies - plain ol' Go stdlib + net/http
Example in go
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("Hello World!"))
})
http.ListenAndServe(":3000", r)
}
installation :
go get github.com/go-chi/chi/v5
continue:go-validator.md