ch6.3
This commit is contained in:
@@ -14,3 +14,11 @@ func secureHeaders(next http.Handler) http.Handler {
|
|||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *application) logRequest(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
app.infoLog.Printf("%s - %s %s %s", r.RemoteAddr, r.Proto, r.Method, r.URL.RequestURI())
|
||||||
|
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ func (app *application) routes() http.Handler {
|
|||||||
mux.HandleFunc("/snippet/view", app.snippetView)
|
mux.HandleFunc("/snippet/view", app.snippetView)
|
||||||
mux.HandleFunc("/snippet/create", app.snippetCreate)
|
mux.HandleFunc("/snippet/create", app.snippetCreate)
|
||||||
|
|
||||||
return secureHeaders(mux)
|
return app.logRequest(secureHeaders(mux))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user