diff --git a/server.go b/server.go index 7af256355..db044fc95 100644 --- a/server.go +++ b/server.go @@ -3,8 +3,6 @@ package courier import ( "bytes" "fmt" - "io" - "io/ioutil" "log" "net/http" "net/http/httputil" @@ -63,7 +61,6 @@ func NewServerWithLogger(config *config.Courier, backend Backend, logger *logrus router.Use(middleware.DefaultCompress) router.Use(middleware.RequestID) router.Use(middleware.RealIP) - router.Use(traceErrors(logger)) router.Use(lg.RequestLogger(logger)) router.Use(middleware.Recoverer) router.Use(middleware.Timeout(15 * time.Second)) @@ -377,26 +374,6 @@ func (s *server) handleIndex(w http.ResponseWriter, r *http.Request) { w.Write(buf.Bytes()) } -func traceErrors(logger *logrus.Logger) func(next http.Handler) http.Handler { - return func(next http.Handler) http.Handler { - fn := func(w http.ResponseWriter, r *http.Request) { - body := bytes.Buffer{} - r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &body)) - ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor) - next.ServeHTTP(ww, r) - - // we are returning an error of some kind, log the incoming request body - if ww.Status() != 200 && strings.ToLower(r.Method) == "post" { - logger.WithFields(logrus.Fields{ - "request_body": body.String(), - "status": ww.Status(), - "req_id": r.Context().Value(middleware.RequestIDKey)}).Error() - } - } - return http.HandlerFunc(fn) - } -} - var splash = ` ____________ _____ ___ ____/_________ ___________(_)____________