diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/http.go | 1 | ||||
-rw-r--r-- | src/http/middlewares.go | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/http/http.go b/src/http/http.go index 49efdec..bca2d79 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -16,6 +16,7 @@ import ( // Server defines and runs an HTTP server func Server() { r := mux.NewRouter() + r.Use(loggingMiddleware) // static js / css hosting assets := r.PathPrefix("/assets/").Subrouter() diff --git a/src/http/middlewares.go b/src/http/middlewares.go new file mode 100644 index 0000000..66258cd --- /dev/null +++ b/src/http/middlewares.go @@ -0,0 +1,16 @@ +package http + +import ( + "net/http" + + "github.com/sirupsen/logrus" +) + +func loggingMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Do stuff here + logrus.Debugf("%s %s", r.Method, r.RequestURI) + // Call the next handler, which can be another middleware in the chain, or the final handler. + next.ServeHTTP(w, r) + }) +} |