Skip to content

Commit 0705180

Browse files
authored
Add httpoison_module environment variable (#154)
Make it possible to use a custom HTTPoison wrapper module.
1 parent f9a3df8 commit 0705180

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ config :panoramix,
3434
http_username: "username",
3535
http_password: "password"
3636
]
37-
]
37+
],
38+
httpoison_module: HTTPoison
3839
```
3940

4041
* `request_timeout`: Query timeout in millis to be used in [`Context`](context-druid-doc-link) of all Druid queries.
4142
* `query_priority`: Priority to be used in [`Context`](context-druid-doc-link) of all Druid queries.
43+
* `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.
4244

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

lib/panoramix.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ defmodule Panoramix do
183183

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

187-
with {:ok, http_response} <- HTTPoison.request(method, url, body, headers, options),
188+
with {:ok, http_response} <- httpoison_module.request(method, url, body, headers, options),
188189
{:ok, body} <- maybe_handle_druid_error(http_response) do
189190
Jason.decode(body)
190191
end

0 commit comments

Comments
 (0)