diff --git a/middlewares/error_pages.go b/middlewares/error_pages.go index 3ef49f11d..d1910fd64 100644 --- a/middlewares/error_pages.go +++ b/middlewares/error_pages.go @@ -19,7 +19,7 @@ type ErrorPagesHandler struct { } //NewErrorPagesHandler initializes the utils.ErrorHandler for the custom error pages -func NewErrorPagesHandler(errorPage types.ErrorPage, backendURL string) (*ErrorPagesHandler, error) { +func NewErrorPagesHandler(errorPage *types.ErrorPage, backendURL string) (*ErrorPagesHandler, error) { fwd, err := forward.New() if err != nil { return nil, err diff --git a/middlewares/error_pages_test.go b/middlewares/error_pages_test.go index 3c70e0a5d..c90093baf 100644 --- a/middlewares/error_pages_test.go +++ b/middlewares/error_pages_test.go @@ -21,7 +21,7 @@ func TestErrorPage(t *testing.T) { testErrorPage := &types.ErrorPage{Backend: "error", Query: "/test", Status: []string{"500-501", "503-599"}} - testHandler, err := NewErrorPagesHandler(*testErrorPage, ts.URL) + testHandler, err := NewErrorPagesHandler(testErrorPage, ts.URL) require.NoError(t, err) assert.Equal(t, testHandler.BackendURL, ts.URL+"/test", "Should be equal") @@ -39,9 +39,11 @@ func TestErrorPage(t *testing.T) { n.ServeHTTP(recorder, req) - assert.Equal(t, http.StatusOK, recorder.Code, "HTTP statusOK") + assert.Equal(t, http.StatusOK, recorder.Code, "HTTP status") assert.Contains(t, recorder.Body.String(), "traefik") + // ---- + handler500 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) fmt.Fprintln(w, "oops") @@ -86,7 +88,7 @@ func TestErrorPageQuery(t *testing.T) { testErrorPage := &types.ErrorPage{Backend: "error", Query: "/{status}", Status: []string{"503-503"}} - testHandler, err := NewErrorPagesHandler(*testErrorPage, ts.URL) + testHandler, err := NewErrorPagesHandler(testErrorPage, ts.URL) require.NoError(t, err) assert.Equal(t, testHandler.BackendURL, ts.URL+"/{status}", "Should be equal") @@ -125,7 +127,7 @@ func TestErrorPageSingleCode(t *testing.T) { testErrorPage := &types.ErrorPage{Backend: "error", Query: "/{status}", Status: []string{"503"}} - testHandler, err := NewErrorPagesHandler(*testErrorPage, ts.URL) + testHandler, err := NewErrorPagesHandler(testErrorPage, ts.URL) require.NoError(t, err) assert.Equal(t, testHandler.BackendURL, ts.URL+"/{status}", "Should be equal") diff --git a/provider/docker/config_container_docker_test.go b/provider/docker/config_container_docker_test.go index 3a666deb2..deb6bd5c5 100644 --- a/provider/docker/config_container_docker_test.go +++ b/provider/docker/config_container_docker_test.go @@ -213,7 +213,7 @@ func TestDockerBuildConfiguration(t *testing.T) { Rule: "Host:test1.docker.localhost", }, }, - Errors: map[string]types.ErrorPage{ + Errors: map[string]*types.ErrorPage{ "foo": { Status: []string{"404"}, Query: "foo_query", diff --git a/types/types.go b/types/types.go index 3217547bf..7b2b7a7db 100644 --- a/types/types.go +++ b/types/types.go @@ -142,18 +142,18 @@ func (h Headers) HasSecureHeadersDefined() bool { // Frontend holds frontend configuration. type Frontend struct { - EntryPoints []string `json:"entryPoints,omitempty"` - Backend string `json:"backend,omitempty"` - Routes map[string]Route `json:"routes,omitempty"` - PassHostHeader bool `json:"passHostHeader,omitempty"` - PassTLSCert bool `json:"passTLSCert,omitempty"` - Priority int `json:"priority"` - BasicAuth []string `json:"basicAuth"` - WhitelistSourceRange []string `json:"whitelistSourceRange,omitempty"` - Headers Headers `json:"headers,omitempty"` - Errors map[string]ErrorPage `json:"errors,omitempty"` - RateLimit *RateLimit `json:"ratelimit,omitempty"` - Redirect *Redirect `json:"redirect,omitempty"` + EntryPoints []string `json:"entryPoints,omitempty"` + Backend string `json:"backend,omitempty"` + Routes map[string]Route `json:"routes,omitempty"` + PassHostHeader bool `json:"passHostHeader,omitempty"` + PassTLSCert bool `json:"passTLSCert,omitempty"` + Priority int `json:"priority"` + BasicAuth []string `json:"basicAuth"` + WhitelistSourceRange []string `json:"whitelistSourceRange,omitempty"` + Headers Headers `json:"headers,omitempty"` + Errors map[string]*ErrorPage `json:"errors,omitempty"` + RateLimit *RateLimit `json:"ratelimit,omitempty"` + Redirect *Redirect `json:"redirect,omitempty"` } // Redirect configures a redirection of an entry point to another, or to an URL