Write requests to log in debug mode
@@ -1382,7 +1382,16 @@ func setupMiddlewares(handler http.Handler) http.Handler {
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logging and metrics
func setupGlobalMiddleware(handler http.Handler) http.Handler {
- return handler
+ return addLogging(handler)
+}
+
+func addLogging(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if serverConfig.Environment.Debug {
+ log.Printf("Received request: %+v %+v\n", r.Method, r.URL)
+ }
+ next.ServeHTTP(w, r)
+ })
}
// This function loads the Contextionary database, and creates
