howdy/env

Configuration from the process environment, read once at startup.

Howdy apps take their settings from environment variables in main, build their configuration values from them, and pass those values into the app. Nothing reads the environment per request.

pub fn main() -> Nil {
  let port = env.int_or("PORT", 8787)
  let assert Ok(database_url) = env.get("DATABASE_URL")
  ...
}

An unset variable and an empty one are both Error(Nil): a deployment that sets SMTP_URL= has not configured SMTP.

Values

pub fn flag(name: String) -> Bool

Whether name is set to true, 1, yes or on, in any case.

pub fn get(name: String) -> Result(String, Nil)

The value of name, or Error(Nil) when it is unset or empty.

pub fn get_or(name: String, default: String) -> String

The value of name, or default when it is unset or empty.

pub fn int(name: String) -> Result(Int, Nil)

The value of name as an integer, or Error(Nil) when it is unset, empty or not a whole number.

pub fn int_or(name: String, default: Int) -> Int

The value of name as an integer, or default when it is unset, empty or not a whole number.

✨ Search Document