Merge 5f06c7525a85be1a380102be2c9c8dd882157082 into c3abaf9afcd167475951249d5a406ba10b24a1d9

This commit is contained in:
Alexander 2014-07-21 09:37:40 +00:00
commit 8ac081bad1

View File

@ -4,11 +4,12 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"log"
"net/http"
"github.com/gin-gonic/gin/binding" "github.com/gin-gonic/gin/binding"
"github.com/gin-gonic/gin/render" "github.com/gin-gonic/gin/render"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"log"
"net/http"
) )
const ( const (
@ -124,6 +125,13 @@ func (c *Context) Fail(code int, err error) {
c.Abort(code) c.Abort(code)
} }
// Redirect replies to the request with a redirect to url,
// which may be a path relative to the request path.
func (c *Context) Redirect(urlStr string) {
http.Redirect(c.Writer, c.Request, urlStr, http.StatusFound)
c.Abort(-1) // About with code < 0, so that don't WriteHeader twice.
}
func (c *Context) ErrorTyped(err error, typ uint32, meta interface{}) { func (c *Context) ErrorTyped(err error, typ uint32, meta interface{}) {
c.Errors = append(c.Errors, errorMsg{ c.Errors = append(c.Errors, errorMsg{
Err: err.Error(), Err: err.Error(),