Etoex

Etoex — библиотека для последовательного выполнения HTTP-операций (pipeline) с:

Installation

def deps do
  [
    {:etoex, "~> 0.1"}
  ]
end

## Quick start

client =

Etoex.client(
  base_url: "https://jsonplaceholder.typicode.com",
  recv_timeout: 30_000
)

ops = [

%{request: {:get, "/posts/1"}, save: %{USER_ID: "userId"}},
%{request: {:get, "/users/<USER_ID>"}}

]

= Etoex.run(client, ops) report.assigns report.results


## Auth

### Bearer

client = Etoex.client(

base_url: "https://api.example.com",
auth: {Etoex.Auth.Bearer, token: "TOKEN"}

)


### Static headers

client = Etoex.client(

base_url: "https://api.example.com",
auth: {Etoex.Auth.StaticHeaders, headers: [{"Authorization", "Bearer TOKEN"}]}

)


### Stack

client = Etoex.client(

base_url: "https://api.example.com",
auth: {Etoex.Auth.Stack, auths: [
  {Etoex.Auth.Bearer, token: "TOKEN"},
  {Etoex.Auth.StaticHeaders, headers: %{"X-Trace-Id" => "abc"}}
]}

)


### TLS

client.tls прокидывается в hackney как ssl_options.
Пример (если используешь certifi в своём приложении):

client = Etoex.client(

base_url: "https://api.example.com",
tls: [verify: :verify_peer, cacertfile: :certifi.cacertfile()]

)


### Livebook (Kino)

Etoex.draw(client, ops)


### Integration tests

По умолчанию внешняя сеть выключена:

mix test mix test --include integration