1
0
mirror of https://github.com/labstack/echo.git synced 2025-06-15 00:14:57 +02:00

Handling 405 & pre-flight requests

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-10-06 06:48:33 -07:00
parent 1efe837fdd
commit 5b019c507e
6 changed files with 121 additions and 145 deletions

View File

@ -382,12 +382,15 @@ func TestEchoNotFound(t *testing.T) {
assert.Equal(t, http.StatusNotFound, w.Code)
}
func TestEchoBadRequest(t *testing.T) {
func TestEchoMethodNotAllowed(t *testing.T) {
e := New()
r, _ := http.NewRequest("INVALID", "/files", nil)
e.Get("/", func(c *Context) error {
return c.String(http.StatusOK, "Echo!")
})
r, _ := http.NewRequest(POST, "/", nil)
w := httptest.NewRecorder()
e.ServeHTTP(w, r)
assert.Equal(t, http.StatusBadRequest, w.Code)
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
}
func TestEchoHTTPError(t *testing.T) {