diff options
author | 2018-04-27 20:38:46 -0700 | |
---|---|---|
committer | 2018-04-27 20:38:46 -0700 | |
commit | 6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7 (patch) | |
tree | 48352d35fa9f3559df05accf4ce4fce1672a2830 /middleware/logging.go | |
parent | 322b265d7aec7731f7fa703c9a74ceb61ae73f3f (diff) | |
download | v2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.tar.gz v2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.tar.zst v2-6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7.zip |
Use Gorilla middleware (refactoring)
Diffstat (limited to 'middleware/logging.go')
-rw-r--r-- | middleware/logging.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/middleware/logging.go b/middleware/logging.go new file mode 100644 index 00000000..6fc506a3 --- /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) + }) +} |