Issue #1086
(t *testing.T)
| 151 | |
| 152 | // Issue #1086 |
| 153 | func TestEchoRewritePreMiddleware(t *testing.T) { |
| 154 | e := echo.New() |
| 155 | |
| 156 | // Rewrite old url to new one |
| 157 | // middlewares added with `Pre()` are executed before routing is done and therefore change which handler matches |
| 158 | e.Pre(RewriteWithConfig(RewriteConfig{ |
| 159 | Rules: map[string]string{"/old": "/new"}}), |
| 160 | ) |
| 161 | |
| 162 | // Route |
| 163 | e.Add(http.MethodGet, "/new", func(c *echo.Context) error { |
| 164 | return c.NoContent(http.StatusOK) |
| 165 | }) |
| 166 | |
| 167 | req := httptest.NewRequest(http.MethodGet, "/old", nil) |
| 168 | rec := httptest.NewRecorder() |
| 169 | e.ServeHTTP(rec, req) |
| 170 | assert.Equal(t, "/new", req.URL.EscapedPath()) |
| 171 | assert.Equal(t, http.StatusOK, rec.Code) |
| 172 | } |
| 173 | |
| 174 | // Issue #1143 |
| 175 | func TestRewriteWithConfigPreMiddleware_Issue1143(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…