1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Merge pull request #138 from chrisseto/feature/redirect-return

Context.Redirect now returns an error
This commit is contained in:
Vishal Rana 2015-07-15 08:01:47 -07:00
commit 533792b86c
2 changed files with 3 additions and 2 deletions

View File

@ -170,8 +170,9 @@ func (c *Context) NoContent(code int) error {
}
// Redirect redirects the request using http.Redirect with status code.
func (c *Context) Redirect(code int, url string) {
func (c *Context) Redirect(code int, url string) error {
http.Redirect(c.response, c.request, url, code)
return nil
}
// Error invokes the registered HTTP error handler. Generally used by middleware.

View File

@ -139,7 +139,7 @@ func TestContext(t *testing.T) {
// Redirect
rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New())
c.Redirect(http.StatusMovedPermanently, "http://labstack.github.io/echo")
assert.Equal(t, nil, c.Redirect(http.StatusMovedPermanently, "http://labstack.github.io/echo"))
// Error
rec = httptest.NewRecorder()