Track is a fast and lightweight HTTP router for Go built using Trie/Prefix data structure, which doesn't break the standard net/http handler.
go get -u github.com/monirz/track
package main
import (
"fmt"
"net/http"
"github.com/monirz/track"
)
func main() {
router := track.New()
router.Get("/users", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello users!")
})
http.ListenAndServe(":8090", router)
}
func main() {
r := track.New()
r.Use(track.CORSMethodMiddleware(r))
r.Get("/users", userHandler)
r.Options("/users", userHandler)
http.ListenAndServe(":8090", r)
}
$ go test -v .
$ go test -bench=.