您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

18 行
404B

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