You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
325B

  1. package middleware
  2. import (
  3. "net/http"
  4. "time"
  5. "github.com/Sirupsen/logrus"
  6. )
  7. func Logger(next http.Handler) http.Handler {
  8. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  9. start := time.Now()
  10. next.ServeHTTP(w, r)
  11. logrus.Debugf("%s - %s (%v)", r.Method, r.URL.Path, time.Since(start))
  12. })
  13. }