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:
commit
533792b86c
@ -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.
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user