From 8164367762d92d330be79c06bde1b484db6a8073 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 23 Sep 2014 23:54:38 +0800 Subject: [PATCH] beego: flash add success & Set --- flash.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/flash.go b/flash.go index 6e85141f..5ccf339a 100644 --- a/flash.go +++ b/flash.go @@ -32,6 +32,24 @@ func NewFlash() *FlashData { } } +// Set message to flash +func (fd *FlashData) Set(key string, msg string, args ...interface{}) { + if len(args) == 0 { + fd.Data[key] = msg + } else { + fd.Data[key] = fmt.Sprintf(msg, args...) + } +} + +// Success writes success message to flash. +func (fd *FlashData) Success(msg string, args ...interface{}) { + if len(args) == 0 { + fd.Data["success"] = msg + } else { + fd.Data["success"] = fmt.Sprintf(msg, args...) + } +} + // Notice writes notice message to flash. func (fd *FlashData) Notice(msg string, args ...interface{}) { if len(args) == 0 {