Skip to content

Commit

Permalink
Add httpoison_module environment variable (#154)
Browse files Browse the repository at this point in the history
Make it possible to use a custom HTTPoison wrapper module.
  • Loading branch information
legoscia authored Sep 6, 2023
1 parent f9a3df8 commit 0705180
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ config :panoramix,
http_username: "username",
http_password: "password"
]
]
],
httpoison_module: HTTPoison
```

* `request_timeout`: Query timeout in millis to be used in [`Context`](context-druid-doc-link) of all Druid queries.
* `query_priority`: Priority to be used in [`Context`](context-druid-doc-link) of all Druid queries.
* `httpoison_module`: Module to call when making HTTP requests. Defaults to `HTTPoison` if not specified, but you can provide a custom wrapper module if you wish. See [HTTPoison.Base](https://hexdocs.pm/httpoison/HTTPoison.Base.html) for examples.

[context-druid-doc-link]: http://druid.io/docs/latest/querying/query-context.html

Expand Down
3 changes: 2 additions & 1 deletion lib/panoramix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ defmodule Panoramix do

url = broker_profile[:base_url] <> url_path
options = http_options(url, broker_profile)
httpoison_module = Application.get_env(:panoramix, :httpoison_module, HTTPoison)

with {:ok, http_response} <- HTTPoison.request(method, url, body, headers, options),
with {:ok, http_response} <- httpoison_module.request(method, url, body, headers, options),
{:ok, body} <- maybe_handle_druid_error(http_response) do
Jason.decode(body)
end
Expand Down

0 comments on commit 0705180

Please sign in to comment.