Translixir.Http.Client (translixir v0.4.0) View Source
Módule containing the Client configurations
Link to this section Summary
Functions
auth
includes field :auth
at struct Client contained at <PID>, it is the authorization token
endpoint
returns the endpoin for Client at <PID>
.
get
returns struct Client
contained at <PID>
headers
returns the request headers for Client at <PID>.
If :auth
is present
returns [{"Content-Type", "application/edn"}, {"Authorization", "Bearer token"}]
else
returns [{"Content-Type", "application/edn"}]
new
creates an Agent that contains structs Client
with fields :host, :port
Link to this section Functions
auth
includes field :auth
at struct Client contained at <PID>, it is the authorization token
{:ok, client} = Client.new("localhost", "3000")
Client.auth(client, "token")
assert Client.headers(client) == [
{"Content-Type", "application/edn"},
{"Authorization", "Bearer token"}
]
endpoint
returns the endpoin for Client at <PID>
.
:tx_log => "http://base_url/tx-log"
:entity => "http://#base_url/entity"
:entity_tx => "http://base_url/entity-tx"
:entity_history => "http://base_url/entity-history"
{:ok, client} = Client.new("localhost", "3000")
assert Client.endpoint(client, :tx_log) == "http://localhost:3000/tx-log"
assert Client.endpoint(client, :entity) == "http://localhost:3000/entity"
assert Client.endpoint(client, :entity_tx) == "http://localhost:3000/entity-tx"
assert Client.endpoint(client, :entity_history) == "http://localhost:3000/entity-history"
assert Client.endpoint(client, :query) == "http://localhost:3000/query"
get
returns struct Client
contained at <PID>
headers
returns the request headers for Client at <PID>.
If :auth
is present
returns [{"Content-Type", "application/edn"}, {"Authorization", "Bearer token"}]
else
returns [{"Content-Type", "application/edn"}]
{:ok, client} = Client.new("localhost", "3000")
assert Client.headers(client) == [{"Content-Type", "application/edn"}]
new
creates an Agent that contains structs Client
with fields :host, :port