package main import ( "fmt" "net/http" "github.com/zenazn/goji" "github.com/zenazn/goji/web" ) func hello(c web.C, w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %s!", c.URLParams["name"]) } var routes = []string{ "/", "/hello", "/hello/:name", } // Middleware returns a http.Handler that does the actual permission setting. func middleware(c *web.C, h http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { // Store the current required permission. for _, resource := range routes { if web.ParsePattern(resource).Match(r, c) { fmt.Println("match!") break } else { fmt.Println("no match..") } } h.ServeHTTP(w, r) } return http.HandlerFunc(fn) } func main() { goji.Get("/hello/:name", hello) goji.Use(middleware) goji.Serve() }