logging.go 571 B

1234567891011121314151617181920
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package middleware
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/http/request"
  8. "github.com/miniflux/miniflux/logger"
  9. )
  10. // Logging logs the HTTP request.
  11. func (m *Middleware) Logging(next http.Handler) http.Handler {
  12. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  13. logger.Debug("[HTTP] %s %s %s", request.RealIP(r), r.Method, r.RequestURI)
  14. next.ServeHTTP(w, r)
  15. })
  16. }