wolf
A very simple (~200 LoC) web "framework" that simply integrates httprouter and x/net/context.
Example
package main
import (
"fmt"
"log"
"net/http"
"github.com/andrew-d/wolf"
"golang.org/x/net/context"
)
func main() {
m := wolf.New()
m.Use(myMiddleware)
m.Get("/", func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello world")
})
log.Println("Started")
http.ListenAndServe(":3001", m)
}
func myMiddleware(ctx *context.Context, h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Printf("Got request to: %s", r.URL)
h.ServeHTTP(w, r)
})
}
License
MIT