Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sujit-baniya committed Sep 14, 2022
2 parents fad7462 + cc9bd27 commit d17a21d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ func (f *Flash) WithSuccess(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
return c
}

func (f *Flash) WithWarn(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
f.data = data
f.warn(c)
return c
}

func (f *Flash) WithInfo(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
f.data = data
f.info(c)
return c
}

func (f *Flash) error(c *fiber.Ctx) {
f.data["error"] = true
f.setCookie(c)
Expand All @@ -98,6 +110,16 @@ func (f *Flash) success(c *fiber.Ctx) {
f.setCookie(c)
}

func (f *Flash) warn(c *fiber.Ctx) {
f.data["warn"] = true
f.setCookie(c)
}

func (f *Flash) info(c *fiber.Ctx) {
f.data["info"] = true
f.setCookie(c)
}

func (f *Flash) setCookie(c *fiber.Ctx) {
var flashValue string
for key, value := range f.data {
Expand Down Expand Up @@ -134,6 +156,14 @@ func WithSuccess(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
return DefaultFlash.WithSuccess(c, data)
}

func WithWarn(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
return DefaultFlash.WithWarn(c, data)
}

func WithInfo(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
return DefaultFlash.WithInfo(c, data)
}

func WithData(c *fiber.Ctx, data fiber.Map) *fiber.Ctx {
DefaultFlash.data = data
return c
Expand Down

0 comments on commit d17a21d

Please sign in to comment.