Description
A DSL for building chainable, composable HTTP requests. API structure taken from
the lovely elm-http-builder.
Currently comes with adapters for HTTPoison, HTTPotion, Hackney and
IBrowse.
Documentation can be found at
https://hexdocs.pm/http_builder.
It's early days still. Feedback welcome!
HttpBuilder alternatives and similar packages
Based on the "HTTP Client" category.
Alternatively, view HttpBuilder alternatives based on common mentions on social networks and blogs.
-
tesla
The flexible HTTP client library for Elixir, with support for middleware and multiple adapters. -
httpotion
[Deprecated because ibrowse is not maintained] HTTP client for Elixir (use Tesla please) -
Maxwell
Maxwell is an HTTP client which support for middleware and multiple adapters.
Learn Elixir in as little as 12 Weeks
Do you think we are missing an alternative of HttpBuilder or a related project?
README
HttpBuilder
A DSL for building chainable, composable HTTP requests. API structure taken from the lovely elm-http-builder.
Currently comes with adapters for HTTPoison
, HTTPotion
, Hackney
and
IBrowse
. JSON parsers are configurable, but defaults to Poison
if present.
Documentation can be found at https://hexdocs.pm/http_builder.
It's early days still. Feedback welcome!
Example Usage
defmodule MyApp.APIClient do
import HttpBuilder
@adapter Application.get_env(:my_app, :http_adapter)
def client() do
# Alternatively - use HttpBuilder.cast/1 with a map of options.
HttpBuilder.new()
|> with_host("https://some-api.org")
|> with_adapter(@adapter)
|> with_headers(%{
"Authorization" => "Bearer #{MyApp.getToken()}",
"Content-Type" => "application/json"
})
end
def submit_widget(body) do
client()
|> post("/v1/path/to/submit")
|> with_body(body)
|> send()
end
def get_widget do
client()
|> get("/v1/path/to/fetch")
|> with_query_params(%{"offset" => 10, "limit" => 5})
|> with_request_timeout(10 * 1000)
|> with_receive_timeout(5 * 1000)
|> send()
end
end
Installation
def deps do
[
{:http_builder, "~> 0.4.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/http_builder.