wisp_flash

Functions

pub fn get_flash(
  request: Request(Connection),
  next: fn(Option(String), Option(String)) -> Response(Body),
) -> Response(Body)

Get the flash message and kind. This middleware goes around your request. This gets the values from the cookies and then deletes them. The middleware callback will return the alert kind and message. After putting these values in the context, you can use them to render alerts in your view.

Example

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

let ctx = Context(..ctx, flash_kind: kind, flash_message: message)
pub fn set_flash(
  response response: Response(Body),
  request request: Request(Connection),
  kind kind: String,
  message message: String,
) -> Response(Body)

Set a flash message in the session cookie. This will store two cookies. One for the message and one for the notification kind.

Example

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