beego: flash add success & Set

This commit is contained in:
astaxie 2014-09-23 23:54:38 +08:00
parent e1475b72b9
commit 8164367762
1 changed files with 18 additions and 0 deletions

View File

@ -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 {