beego: flash add success & Set
Showing
1 changed file
with
18 additions
and
0 deletions
| ... | @@ -32,6 +32,24 @@ func NewFlash() *FlashData { | ... | @@ -32,6 +32,24 @@ func NewFlash() *FlashData { |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | // Set message to flash | ||
| 36 | func (fd *FlashData) Set(key string, msg string, args ...interface{}) { | ||
| 37 | if len(args) == 0 { | ||
| 38 | fd.Data[key] = msg | ||
| 39 | } else { | ||
| 40 | fd.Data[key] = fmt.Sprintf(msg, args...) | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | // Success writes success message to flash. | ||
| 45 | func (fd *FlashData) Success(msg string, args ...interface{}) { | ||
| 46 | if len(args) == 0 { | ||
| 47 | fd.Data["success"] = msg | ||
| 48 | } else { | ||
| 49 | fd.Data["success"] = fmt.Sprintf(msg, args...) | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 35 | // Notice writes notice message to flash. | 53 | // Notice writes notice message to flash. |
| 36 | func (fd *FlashData) Notice(msg string, args ...interface{}) { | 54 | func (fd *FlashData) Notice(msg string, args ...interface{}) { |
| 37 | if len(args) == 0 { | 55 | if len(args) == 0 { | ... | ... |
-
Please register or sign in to post a comment