qs
Types
pub type Config {
Config(fail_on_invalid: Bool)
}
Constructors
-
Config(fail_on_invalid: Bool)
pub type QueryBasic =
dict.Dict(String, List(String))
Values
pub fn default_config() -> Config
pub fn default_parse(
qs: String,
) -> Result(dict.Dict(String, List(String)), String)
Parse a query string. Values that cannot be parsed are ignored.
Example
"?color=red&tags=large&tags=wool"
|> qs.default_parse
==
Ok(
dict.from_list(
[ #("color", ["red"]), #("tags", ["large", "wool"]) ]
)
)
pub fn default_serialize(
query: dict.Dict(String, List(String)),
) -> String
Serialize a query
Example
[ #("color", ["red"]), #("tag", ["large", "wool"]) ]
|> qs.default_serialize
==
"?color=red&tag=large&tag=wool"
pub fn delete(
query: dict.Dict(String, a),
key: String,
) -> dict.Dict(String, a)
Delete a key from the query
pub fn get(
query: dict.Dict(String, v),
key: String,
) -> Result(v, String)
Get values from the query
pub fn has_key(query: dict.Dict(String, b), key: String) -> Bool
Tell if the query has the given key
pub fn insert(
query: dict.Dict(String, b),
key: String,
value: b,
) -> dict.Dict(String, b)
Insert a value in the query Replaces existing values
pub fn merge(
a: dict.Dict(String, a),
b: dict.Dict(String, a),
) -> dict.Dict(String, a)
Merge two Querys. Second query takes precedence.