I am using gorilla mux for manage routing. What I am missing is to integrate a middleware between every request.
For example
package main
import (
I'm not sure why @OneOfOne chose to chain router into the Middleware, I think this is slight better approach:
func main() {
r.Handle("/",Middleware(http.HandlerFunc(homeHandler)))
http.Handle("/", r)
}
func Middleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTP(w, r)
})}