diff options
Diffstat (limited to 'logger.go')
-rw-r--r-- | logger.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/logger.go b/logger.go new file mode 100644 index 0000000..3f002e3 --- /dev/null +++ b/logger.go @@ -0,0 +1,23 @@ +package main + +import ( + "log" + "net/http" + "time" +) + +func Logger(inner http.Handler, name string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + + inner.ServeHTTP(w, r) + + log.Printf( + "%s\t%s\t%s\t%s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) +} |