This commit is contained in:
lbenedar
2026-03-05 13:04:59 +03:00
parent fc1484aebe
commit fbce0c006c
2 changed files with 9 additions and 1 deletions

View File

@@ -14,3 +14,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)
})
}

View File

@@ -12,5 +12,5 @@ func (app *application) routes() http.Handler {
mux.HandleFunc("/snippet/view", app.snippetView)
mux.HandleFunc("/snippet/create", app.snippetCreate)
return secureHeaders(mux)
return app.logRequest(secureHeaders(mux))
}