HTTP clients
Mix.install([
{:finch, "~> 0.14.0"},
{:httpoison, "~> 2.0.0"},
{:mint, "~> 1.5.0"},
{:req, "~> 0.3.6"},
{:tesla, "~> 1.5.1"}
])
Finch
https://hexdocs.pm/finch/Finch.html
defmodule MyFinch do
end
Finch.start_link(name: MyFinch)
{:ok, resp} = Finch.build(:get, "https://example.com/") |> Finch.request(MyFinch)
{resp.status, String.length(resp.body)}
HTTPoison
https://hexdocs.pm/httpoison/readme.html
HTTPoison.start()
resp = HTTPoison.get!("https://example.com/")
{resp.status_code, String.length(resp.body)}
Tesla
https://hexdocs.pm/tesla/readme.html
defmodule MyTesla do
use Tesla
adapter(Tesla.Adapter.Mint)
end
resp = MyTesla.get!("https://example.com/")
{resp.status, String.length(resp.body)}
Req
https://hexdocs.pm/req/readme.html
resp = Req.get!("https://example.com/")
{resp.status, String.length(resp.body)}