Add request logging
This commit is contained in:
parent
4ce321dc36
commit
c0a73494c3
2 changed files with 9 additions and 1 deletions
|
@ -31,3 +31,11 @@ func secureHeaders(next http.Handler) http.Handler {
|
|||
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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -44,5 +44,5 @@ func (app *application) routes() http.Handler {
|
|||
mux.HandleFunc("/", app.home)
|
||||
mux.HandleFunc("/motions/", app.motionList)
|
||||
|
||||
return secureHeaders(mux)
|
||||
return app.logRequest(secureHeaders(mux))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue