Exemple #1
0
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."
}
Exemple #2
0
func root(c *fogo.Context) (int, interface{}) {
	output, outErr := c.RenderTemplate(nil, "example.tpl")
	if outErr != nil {
		return 500, outErr.Error()
	}
	return 200, output
}
Exemple #3
0
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
}
Exemple #4
0
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
}
Exemple #5
0
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."
}
Exemple #6
0
func deleteCookie(c *fogo.Context) (int, interface{}) {
	c.DeleteSession(SESS_KEY)
	return 200, "Deleted session"
}