package main import ( "fmt" "log" "net/http" "github.com/julienschmidt/httprouter" "github.com/sanity-io/litter" ) func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { fmt.Fprint(w, "Welcome!\n") } func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { c := httprouter.ParamsFromContext(r.Context()) // nil ? fmt.Fprintln(w, litter.Sdump(c)) fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name")) } func main() { router := httprouter.New() router.GET("/", Index) router.GET("/hello/:name", Hello) log.Fatal(http.ListenAndServe(":8080", router)) }