81643677 by astaxie

beego: flash add success & Set

1 parent e1475b72
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 {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!