aboutsummaryrefslogtreecommitdiffhomepage
path: root/middleware/logging.go
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/logging.go')
-rw-r--r--middleware/logging.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/middleware/logging.go b/middleware/logging.go
new file mode 100644
index 0000000..6fc506a
--- /dev/null
+++ b/middleware/logging.go
@@ -0,0 +1,20 @@
+// Copyright 2018 Frédéric Guillot. All rights reserved.
+// Use of this source code is governed by the Apache 2.0
+// license that can be found in the LICENSE file.
+
+package middleware
+
+import (
+ "net/http"
+
+ "github.com/miniflux/miniflux/logger"
+ "github.com/tomasen/realip"
+)
+
+// Logging logs the HTTP request.
+func (m *Middleware) Logging(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ logger.Debug("[HTTP] %s %s %s", realip.RealIP(r), r.Method, r.RequestURI)
+ next.ServeHTTP(w, r)
+ })
+}