wisp/wisp_mist

Values

pub fn handler(
  handler: fn(request.Request(@internal Connection)) -> response.Response(
    wisp.Body,
  ),
  secret_key_base: String,
) -> fn(request.Request(@internal Connection)) -> response.Response(
  mist.ResponseData,
)

Convert a Wisp request handler into a function that can be run with the Mist web server.

Examples

pub fn main() {
  let secret_key_base = "..."
  let assert Ok(_) =
    handle_request
    |> wisp_mist.handler(secret_key_base)
    |> mist.new
    |> mist.port(8000)
    |> mist.start_http
  process.sleep_forever()
}

The secret key base is used for signing and encryption. To be able to verify and decrypt messages you will need to use the same key each time your program is run. Keep this value secret! Malicious people with this value will likely be able to hack your application.

Search Document