From 126a2b2f7c2a5f435d7ca1334b4df3eb3b9fc692 Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Thu, 2 Jun 2016 22:42:39 +0300 Subject: [PATCH] Fix redirect when POST method --- context_response.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/context_response.go b/context_response.go index 59c9a09f..4f663d0b 100644 --- a/context_response.go +++ b/context_response.go @@ -13,13 +13,12 @@ func (ctx *Context) SetHeader(k string, v string) { // Redirect redirect sends a redirect response the client // accepts 2 parameters string and an optional int // first parameter is the url to redirect -// second parameter is the http status should send, default is 307 (Temporary redirect), you can set it to 301 (Permant redirect), if that's nessecery +// second parameter is the http status should send, default is 302 (StatusFound), you can set it to 301 (Permant redirect), if that's nessecery func (ctx *Context) Redirect(urlToRedirect string, statusHeader ...int) { - httpStatus := StatusTemporaryRedirect // temporary redirect + httpStatus := StatusFound // temporary redirect if statusHeader != nil && len(statusHeader) > 0 && statusHeader[0] > 0 { httpStatus = statusHeader[0] } - ctx.RequestCtx.Redirect(urlToRedirect, httpStatus) ctx.StopExecution() } @@ -28,7 +27,7 @@ func (ctx *Context) Redirect(urlToRedirect string, statusHeader ...int) { func (ctx *Context) RedirectTo(routeName string, args ...interface{}) { s, ok := ctx.station.RouteByName(routeName).Parse(args...) if ok { - ctx.Redirect(s, StatusTemporaryRedirect) + ctx.Redirect(s, StatusFound) } }