Files
phoenix-ausblick/lib/outlook/hyphenation.ex

32 lines
617 B
Elixir

defmodule Outlook.Hyphenation do
def hyphenate(html, lang) do
form = get_multipart_form(
[
{"api-token", System.get_env("HYPH_API_TOKEN")},
{"hyph[lang]", String.downcase(lang)},
{"hyph[text]", html},
]
)
response_raw = HTTPoison.request!(
:post,
System.get_env("HYPH_URL"),
form,
get_multipart_headers()
)
response_raw.body
end
defp get_multipart_form fields do
{:multipart, fields}
end
defp get_multipart_headers() do
[
"Content-Type": "multipart/form-data",
"Transfer-Encoding": "chunked",
]
end
end