Support rewriting status codes in error page middleware
This commit is contained in:
parent
f0849e8ee6
commit
fa76ed57d3
18 changed files with 195 additions and 8 deletions
|
@ -69,6 +69,30 @@ func (s *ErrorPagesSuite) TestErrorPage() {
|
|||
require.NoError(s.T(), err)
|
||||
}
|
||||
|
||||
func (s *ErrorPagesSuite) TestStatusRewrites() {
|
||||
// The `statusRewrites.toml` file contains a misconfigured backend host and some status code rewrites.
|
||||
file := s.adaptFile("fixtures/error_pages/statusRewrites.toml", struct {
|
||||
Server1 string
|
||||
Server2 string
|
||||
}{s.BackendIP, s.ErrorPageIP})
|
||||
|
||||
s.traefikCmd(withConfigFile(file))
|
||||
|
||||
frontendReq, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080", nil)
|
||||
require.NoError(s.T(), err)
|
||||
frontendReq.Host = "test502.local"
|
||||
|
||||
err = try.Request(frontendReq, 2*time.Second, try.BodyContains("An error occurred."), try.StatusCodeIs(404))
|
||||
require.NoError(s.T(), err)
|
||||
|
||||
frontendReq, err = http.NewRequest(http.MethodGet, "http://127.0.0.1:8080", nil)
|
||||
require.NoError(s.T(), err)
|
||||
frontendReq.Host = "test418.local"
|
||||
|
||||
err = try.Request(frontendReq, 2*time.Second, try.BodyContains("An error occurred."), try.StatusCodeIs(400))
|
||||
require.NoError(s.T(), err)
|
||||
}
|
||||
|
||||
func (s *ErrorPagesSuite) TestErrorPageFlush() {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Add("Transfer-Encoding", "chunked")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue