From d30d304cea836fe6502173a96e194f596c85512d Mon Sep 17 00:00:00 2001 From: NiseVoid Date: Fri, 30 Nov 2018 14:24:28 +0100 Subject: [PATCH] Add Redirect to Context --- context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/context.go b/context.go index 60ab4df..21b1307 100644 --- a/context.go +++ b/context.go @@ -20,6 +20,11 @@ func newContext(router *Router, res http.ResponseWriter, req *http.Request, para return &Context{router, req, res, param.ByName, make(map[string]interface{})} } +func (c *Context) Redirect(code int, url string) error { + http.Redirect(c.Response, c.Request, url, code) + return nil +} + // String returns the given status code and writes the bytes to the body func (c *Context) Bytes(code int, b []byte) error { c.Response.WriteHeader(code)