type Middleware func(next http.Handler) http.Handler
func Logging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s", r.Method, r.URL.Path)
next.ServeHTTP(w, r)
})
}
mux := http.NewServeMux()
mux.Handle("/", Logging(http.HandlerFunc(home)))
http.ListenAndServe(":8080", mux)