howdy/query
Typed query string extraction with automatic JSON 400 responses.
Required helpers reject missing values; optional_* helpers return None;
*_or helpers use their default only when the key is absent.
Invalid values and duplicate singular keys always fail.
Empty strings are preserved. Booleans accept only true and false.
Repeated values are available through strings, in request order.
use page <- query.int_or(ctx, "page", default: 1)
use search <- query.optional_string(ctx, "search")
Values
pub fn bool(
ctx: context.Context(guarded),
name: String,
next: fn(Bool) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a required boolean. Missing or invalid input returns 400.
pub fn bool_or(
ctx: context.Context(guarded),
name: String,
default default: Bool,
next next: fn(Bool) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a boolean, using default only when the key is absent.
pub fn int(
ctx: context.Context(guarded),
name: String,
next: fn(Int) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a required integer. Missing or invalid input returns 400.
pub fn int_or(
ctx: context.Context(guarded),
name: String,
default default: Int,
next next: fn(Int) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a integer, using default only when the key is absent.
pub fn optional_bool(
ctx: context.Context(guarded),
name: String,
next: fn(option.Option(Bool)) -> response.Response(
content.Content,
),
) -> response.Response(content.Content)
Extract an optional boolean. Invalid input still returns 400.
pub fn optional_int(
ctx: context.Context(guarded),
name: String,
next: fn(option.Option(Int)) -> response.Response(
content.Content,
),
) -> response.Response(content.Content)
Extract an optional integer. Invalid input still returns 400.
pub fn optional_string(
ctx: context.Context(guarded),
name: String,
next: fn(option.Option(String)) -> response.Response(
content.Content,
),
) -> response.Response(content.Content)
Extract an optional string. Invalid input still returns 400.
pub fn string(
ctx: context.Context(guarded),
name: String,
next: fn(String) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a required string. Missing or invalid input returns 400.
pub fn string_or(
ctx: context.Context(guarded),
name: String,
default default: String,
next next: fn(String) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract a string, using default only when the key is absent.
pub fn strings(
ctx: context.Context(guarded),
name: String,
next: fn(List(String)) -> response.Response(content.Content),
) -> response.Response(content.Content)
Extract all values for a key, preserving order and empty strings.
An absent key gives []; invalid query encoding returns 400.