View Source Httpc (ehelper v0.1.3)
Simple HTTP client by wrapping :httpc
httpc
Great httpc cheatsheet post: https://elixirforum.com/t/httpc-cheatsheet/50337
iex> :inets.start :ssl.start :httpc.request 'https://elixir-lang.org'
Summary
Functions
Get url from httpc, copied from https://github.com/phoenixframework/phoenix/blob/v1.7.7/lib/mix/tasks/phx.gen.release.ex#L192
Functions
Get url from httpc, copied from https://github.com/phoenixframework/phoenix/blob/v1.7.7/lib/mix/tasks/phx.gen.release.ex#L192
iex> Httpc.fetch_body2!("https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.14.5-erlang-25.3-debian-bullseye-")
mix eh.fetch https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.14.5-erlang-25.3-debian-bullseye- -m 2
Copied from https://github.com/phoenixframework/phoenix/blob/v1.7.6/test/support/http_client.exs
Performs HTTP Request and returns Response
- method - The http method, for example :get, :post, :put, etc
- url - The string url, for example "http://example.com"
- headers - The map of headers
- body - The optional string body. If the body is a map, it is converted to a URI encoded string of parameters
Examples
iex> Httpc.request(:get, "http://127.0.0.1", %{})
{:ok, %Response{..})
iex> Httpc.request(:post, "http://127.0.0.1", %{}, param1: "val1")
{:ok, %Response{..})
iex> Httpc.request(:get, "http://unknownhost", %{}, param1: "val1")
{:error, ...}