s3manager-web/logger.go
2017-03-05 15:02:59 +01:00

27 lines
392 B
Go

package main
import (
"log"
"net/http"
"time"
)
// Logger logs HTTP requests
func Logger() Middleware {
return func(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
defer func() {
log.Printf(
"%s\t%s\t%s",
r.Method,
r.RequestURI,
time.Since(start),
)
}()
next(w, r)
}
}
}