You create a REST API with the Chi router by importing github.com/go-chi/chi/v5, defining a chi.Mux, registering routes with Handle or HandleFunc, and starting the server with http.ListenAndServe.
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
)
func main() {
r := chi.NewMux()
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
r.Get("/hello/{name}", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello " + chi.URLParam(r, "name")))
})
http.ListenAndServe(":3000", r)
}