httpoison_form_data v0.1.0 FormData.Formatters.URLEncoded
Summary
Functions
Format name
and value
as a key-value tuple
Format a list
of key-value tuples for URL Encoded requests
Functions
Format name
and value
as a key-value tuple.
When the name or value of a parameter are absent, the parameter is ignored.
When the file
variable is present, the parameter is ignored.
It returns a list of name-value tuples.
Examples
iex> FormData.Formatters.URLEncoded.format("Name", "Value", false)
{"Name", "Value"}
iex> FormData.Formatters.URLEncoded.format("Name", "Value", true)
nil
iex> FormData.Formatters.URLEncoded.format("", "Value", false)
nil
iex> FormData.Formatters.URLEncoded.format("Name", "", false)
nil
iex> FormData.Formatters.URLEncoded.format(nil, "Value", false)
nil
iex> FormData.Formatters.URLEncoded.format("Name", nil, false)
nil
iex> FormData.Formatters.URLEncoded.format("Name", "Value", nil)
nil
Format a list
of key-value tuples for URL Encoded requests.
Since URLEncoded parameters can be used in GET and POST requests, the
options
hash includes a :get
option. The default output is valid form
data for a call to HTTPoison.post
. The output with the :get
flag is valid
data for a call to HTTPoison.get
.
If a different HTTP library is in use, or if the URL string needs to be
modified, the :url
flag can be set to output the proper URL string.
Examples
iex> FormData.Formatters.URLEncoded.output([{"Name", "Value"}, {"Name2", "Value2"}], [])
{:form, [{"Name", "Value"}, {"Name2", "Value2"}]}
iex> FormData.Formatters.URLEncoded.output([{"Name", "Value"}, {"Name2", "Value2"}], get: true)
[params: [{"Name", "Value"}, {"Name2", "Value2"}]]
iex> FormData.Formatters.URLEncoded.output([{"Name", "Value"}, {"Name2", "Value2"}], url: true)
"?Name=Value&Name2=Value2"