Skip to main content

Redirect

To redirect to any URL internal or external simply call the response's method Redirect, here is how you can do it:

func SomeHandler(c *core.Context) *core.Response {
return c.Response.Redirect("https://google.com")
}

By default Redirect uses 307 Temporary Redirect, which preserves the HTTP method of the original request. If you want the browser to switch to a GET request after the redirect (for example, after handling a POST form), pass true as a second argument to use 303 See Other:

func Store(c *core.Context) *core.Response {
// ... handle the form submission ...

// Redirect to the newly created resource using GET
return c.Response.Redirect("/users/list", true)
}

Here is a list of all HTTP codes