PassiveSupport.PostBody (passive_support v0.8.3)

Functions for working with www-form-urlencoded data

Link to this section Summary

Functions

Deep-parses the map into a string formatted according to the www-form-urlencoded spec.

Link to this section Functions

Link to this function

form_encoded(enum)

Specs

form_encoded(map()) :: String.t()

Deep-parses the map into a string formatted according to the www-form-urlencoded spec.

Examples

iex> form_encoded(%{
...>   "success_url" => "https://localhost:4001/foo/bert?id={ID}",
...>   "cancel_url" => "https://localhost:4001/foo/bar",
...>   "blips" => ["blop", "blorp", "blep"],
...>   "array" => [
...>     %{"something" => "five dollars", "quantity" => 1},
...>     %{"line" => "line", "item" => "item"},
...>     %{"let's" => ~W[really flerf this up]}
...>   ],
...>   "mode" => "median",
...>   "just_to_make_sure" => %{
...>     "we got" => "all", "the edge" => "cases", "we can think of" => "covered"
...>   }
...> })
~S(array[0][quantity]=1&array[0][something]=five+dollars&array[1][item]=item&array[1][line]=line&array[2][let%27s][0]=really&array[2][let%27s][1]=flerf&array[2][let%27s][2]=this&array[2][let%27s][3]=up&blips[0]=blop&blips[1]=blorp&blips[2]=blep&cancel_url="https://localhost:4001/foo/bar"&just_to_make_sure[the+edge]=cases&just_to_make_sure[we+can+think+of]=covered&just_to_make_sure[we+got]=all&mode=median&success_url="https://localhost:4001/foo/bert?id={ID}")

iex> form_encoded(%{something: :dotcom})
"something=dotcom"