parse_qs(Req :: cowboy_req:req()) -> parse_qs(Req, #{})
parse_qs(Req :: cowboy_req:req(), Opts)
-> [{Key :: binary(), Value :: binary() | true}]
Opts :: #{max_keys => non_neg_integer()}
cowboy_req:parse_qs - Parse the query string
parse_qs(Req :: cowboy_req:req()) -> parse_qs(Req, #{})
parse_qs(Req :: cowboy_req:req(), Opts)
-> [{Key :: binary(), Value :: binary() | true}]
Opts :: #{max_keys => non_neg_integer()}
Parse the query string as a list of key/value pairs.
The Req object.
The max_keys option limits the maximum number of keys in the query string. It defaults to 100.
The parsed query string is returned as a list of key/value pairs. The key is a binary string. The value is either a binary string, or the atom true. Both key and value are case sensitive.
The atom true is returned when a key is present in the query string without a value. For example, in the following URIs the key <<"edit">> will always have the value true:
/posts/42?edit
/posts/42?edit&exclusive=1
/posts/42?exclusive=1&edit
/posts/42?exclusive=1&edit&from=web
parse_qs/2 introduced with a max_keys option.
qs_val/1 and qs_vals/1.
ParsedQs = cowboy_req:parse_qs(Req),
AtomsQs = [{binary_to_existing_atom(K, latin1), V}
|| {K, V} <- ParsedQs].
Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:
Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.