Example #1
0
// AddFlashToCtx takes flash messages stored in a cookie which is associated with the
// request found in ctx, and puts them inside the ctx object. The flash messages can then
// be retrived by calling ctx.Get( FlashKey).
//
// NOTE When there are no flash messages then nothing is set.
func AddFlashToCtx(ctx *base.Context, name, key string) error {
	f, err := GetFlashes(ctx, name, key)
	if err != nil {
		return err
	}
	ctx.SetData(key, f)
	return nil
}