func setCookie(c *fogo.Context) (int, interface{}) { err := c.SetSessionValue(SESS_KEY, KEY, "Cool") if err != nil { return 400, err.Error() } return 200, "Set session value." }
func root(c *fogo.Context) (int, interface{}) { output, outErr := c.RenderTemplate(nil, "example.tpl") if outErr != nil { return 500, outErr.Error() } return 200, output }
func showFlashes(c *fogo.Context) (int, interface{}) { out, outErr := c.RenderTemplate(nil, "flashes.tpl") if outErr != nil { return http.StatusBadRequest, outErr.Error() } return 200, out }
func getCookie(c *fogo.Context) (int, interface{}) { val := c.GetSessionValue(SESS_KEY, KEY) if val == nil { return 200, "No value found." } c.Logger.LogInterfaces("Cookie Value:", val) return 200, val }
func addFlashes(c *fogo.Context) (int, interface{}) { if err := c.AddSuccessFlash("Success flash " + time.Now().String()); err != nil { c.Logger.LogError(err) } if err := c.AddErrorFlash("Error flash " + time.Now().String()); err != nil { c.Logger.LogError(err) } c.Redirect = true c.RedirectPath = "/show_flashes" return http.StatusNotFound, "Not found." }
func deleteCookie(c *fogo.Context) (int, interface{}) { c.DeleteSession(SESS_KEY) return 200, "Deleted session" }