spaceship_helm/cookie

Types

Options for setting cookies.

pub type CookieOptions {
  CookieOptions(
    path: String,
    max_age: Int,
    http_only: Bool,
    secure: Bool,
    same_site: String,
  )
}

Constructors

  • CookieOptions(
      path: String,
      max_age: Int,
      http_only: Bool,
      secure: Bool,
      same_site: String,
    )

Values

pub fn default_options() -> CookieOptions

Default cookie options (http_only, secure, SameSite=Lax, path=“/”).

pub fn delete(
  resp: response.Response(body),
  name: String,
) -> response.Response(body)

Delete a cookie by setting it with max-age 0.

pub fn get(
  req: request.Request(body),
  name: String,
) -> option.Option(String)

Get a cookie value from the request by name.

Returns Some(value) if found, None otherwise.

pub fn get_all(
  req: request.Request(body),
) -> List(#(String, String))

Get all cookies from the request.

Returns a list of (name, value) tuples.

pub fn set(
  resp: response.Response(body),
  name: String,
  value: String,
  max_age: Int,
) -> response.Response(body)

Set a cookie on the response with default settings.

The cookie will be available for the path “/” and expires after max_age seconds.

pub fn set_with_options(
  resp: response.Response(body),
  name: String,
  value: String,
  options: CookieOptions,
) -> response.Response(body)

Set a cookie with full options.

Search Document