gorilla/mux — pull request #36 by scttnlsn (2013-10-07 21:24:19+00:00)
Title: Middleware (handler wrapping)

This adds support for wrapping handler functions with additional functionality. Example:

middleware := func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
fmt.Println("before")
next.ServeHTTP(w, req)
fmt.Println("after")
})
}

r := NewRouter().Use(middleware)

I find this pattern very useful for implementing auth, logging, etc. Is this something you'd be interested in merging into `mux`?