1
0
mirror of https://github.com/containous/traefik.git synced 2024-10-26 17:25:15 +03:00

refactor: minor changes.

This commit is contained in:
Fernandez Ludovic 2017-08-24 00:59:59 +02:00 committed by Traefiker
parent f1a257abf8
commit 8235cd3645
2 changed files with 4 additions and 2 deletions

View File

@ -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{

View File

@ -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.")
})
}
}