Aero is tiny Express-inspired router for golang.
You need go version 1.7++
go get github.com/aldidana/aero
package main
import (
"fmt"
"github.com/aldidana/aero"
"net/http"
)
func main() {
router := aero.Router()
router.Get("/", func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("Index Page"))
})
// Using params
// This handler will match /hello/bingo but it will not match /hello/ and /hello
router.Get("/hello/:name", helloHandler)
http.ListenAndServe(":5678", router)
}
func helloHandler(res http.ResponseWriter, req *http.Request) {
name := req.Context().Value("name")
fmt.Fprintf(res, "Hello %v\n", name)
}
- Testing
- Group several routes
- Maybe route logging 🍻
MIT @Aldi Priya Perdana