Add basic logger
alex wennerberg alex@alexwennerberg.com
Wed, 21 Oct 2020 22:50:11 -0700
1 files changed,
7 insertions(+),
1 deletions(-)
jump to
M
http.go
→
http.go
@@ -88,5 +88,11 @@ http.HandleFunc(c.RootDomain+"/edit/", editFileHandler)
// http.HandleFunc("/delete/", deleteFileHandler) // login+register functions http.HandleFunc("/", userFile) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(":8080", logRequest(http.DefaultServeMux))) +} + +func logRequest(handler http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + log.Printf("%s %s %s\n", r.RemoteAddr, r.Method, r.URL) + }) }