From 8235cd36450f135f3bfde42f508d3e9b91a4de2f Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 24 Aug 2017 00:59:59 +0200 Subject: [PATCH] refactor: minor changes. --- middlewares/stats.go | 2 +- middlewares/stripPrefix_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/middlewares/stats.go b/middlewares/stats.go index faac75eba..61cafdf3d 100644 --- a/middlewares/stats.go +++ b/middlewares/stats.go @@ -80,7 +80,7 @@ func (r *responseRecorder) Flush() { func (s *StatsRecorder) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { recorder := &responseRecorder{w, http.StatusOK} next(recorder, r) - if recorder.statusCode >= 400 { + if recorder.statusCode >= http.StatusBadRequest { s.mutex.Lock() defer s.mutex.Unlock() s.recentErrors = append([]*statsError{ diff --git a/middlewares/stripPrefix_test.go b/middlewares/stripPrefix_test.go index 91a03c404..2103102c1 100644 --- a/middlewares/stripPrefix_test.go +++ b/middlewares/stripPrefix_test.go @@ -93,12 +93,13 @@ func TestStripPrefix(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - var actualPath, actualHeader string + var actualPath, actualHeader, requestURI string handler := &StripPrefix{ Prefixes: test.prefixes, Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { actualPath = r.URL.Path actualHeader = r.Header.Get(ForwardedPrefixHeader) + requestURI = r.RequestURI }), } @@ -110,6 +111,7 @@ func TestStripPrefix(t *testing.T) { assert.Equal(t, test.expectedStatusCode, resp.Code, "Unexpected status code.") assert.Equal(t, test.expectedPath, actualPath, "Unexpected path.") assert.Equal(t, test.expectedHeader, actualHeader, "Unexpected '%s' header.", ForwardedPrefixHeader) + assert.Equal(t, test.expectedPath, requestURI, "Unexpected request URI.") }) } }