wisp_flash

Middleware to add flash messages in Wisp

Package Version Hex Docs

Setting the flash message

In your handler:

wisp.redirect("/home")
|> wisp_flash.set_flash(request, "success", "Document Saved")

Retrieving the flash message

In your router:

use kind, message <- wisp_flash.get_flash(request)

let ctx = Context(..ctx, flash_kind: kind, flash_message: message)

In your view:

fn alert(ctx: Context) {
  case ctx.flash_message {
    Some(flash_message) -> {
      let kind = ctx.flash_kind |> option.unwrap("notice")

      ...
    }
    None -> div([], [])
  }
}
Search Document