Skip to content

monirz/track

Repository files navigation

track

Coverage Actions Status

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.

Install

go get -u github.com/monirz/track

Usage

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)
}

Using middleware

func main() {

	r := track.New()

	r.Use(track.CORSMethodMiddleware(r))
	r.Get("/users", userHandler)
	r.Options("/users", userHandler)

	http.ListenAndServe(":8090", r)

}

Test

$ go test -v . 

Benchmark

$ go test -bench=. 

Releases

No releases published

Packages

No packages published

Languages