From d5c7a43ad50834eb159df573064ffce975204842 Mon Sep 17 00:00:00 2001 From: Manuel Kallenbach Date: Mon, 9 Jan 2017 21:13:19 +0100 Subject: [PATCH 1/3] allow options in search --- lib/elastix/search.ex | 4 ++-- mix.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/elastix/search.ex b/lib/elastix/search.ex index f8b3b85..88bcb68 100644 --- a/lib/elastix/search.ex +++ b/lib/elastix/search.ex @@ -9,9 +9,9 @@ defmodule Elastix.Search do end @doc false - def search(elastic_url, index, types, data, query_params) do + def search(elastic_url, index, types, data, query_params, options \\ []) do elastic_url <> make_path(index, types, query_params) - |> HTTP.post(Poison.encode!(data)) + |> HTTP.post(Poison.encode!(data), options) |> process_response end diff --git a/mix.lock b/mix.lock index c9ff390..4706a5d 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ -%{"bunt": {:hex, :bunt, "0.1.6", "5d95a6882f73f3b9969fdfd1953798046664e6f77ec4e486e6fafc7caad97c6f", [:mix], []}, +%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []}, "certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []}, - "credo": {:hex, :credo, "0.5.3", "0c405b36e7651245a8ed63c09e2d52c2e2b89b6d02b1570c4d611e0fcbecf4a2", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]}, + "credo": {:hex, :credo, "0.6.0", "44a82f82b94eeb4ba6092c89b8a6730ca1a3291c7940739d5acc8806d25ac991", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, optional: false]}]}, "earmark": {:hex, :earmark, "0.1.17", "a2269e72ff85501bdb58c2de9edc0a9a17a4be2757883eed1f601b30494ed2bf", [:mix], []}, "ex_doc": {:hex, :ex_doc, "0.7.3", "8f52bfbfcbc0206dd08dd94aae86a3fd5330ba2f37c73cfea2918ed4c96d1769", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]}, "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []}, From 9063d7bbe2e6f1d90dbddfdf4cced663a98dfadb Mon Sep 17 00:00:00 2001 From: Manuel Kallenbach Date: Fri, 27 Jan 2017 19:43:48 +0100 Subject: [PATCH 2/3] allow setting default httpoison options --- lib/elastix/http.ex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/elastix/http.ex b/lib/elastix/http.ex index cf649b6..452d702 100644 --- a/lib/elastix/http.ex +++ b/lib/elastix/http.ex @@ -34,6 +34,7 @@ defmodule Elastix.HTTP do headers end + options = Keyword.merge(default_httpoison_options(), options) HTTPoison.Base.request(__MODULE__, method, url, body, headers, options, &process_status_code/1, &process_headers/1, &process_response_body/1) end @@ -49,4 +50,8 @@ defmodule Elastix.HTTP do defp poison_options do Elastix.config(:poison_options, []) end + + defp default_httpoison_options do + Elastix.config(:httpoison_options, []) + end end From a3cb59b5d7cb272e824109047ce6beba8bcde69b Mon Sep 17 00:00:00 2001 From: Manuel Kallenbach Date: Thu, 2 Mar 2017 18:44:33 +0100 Subject: [PATCH 3/3] add httpoison options example to readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66e9ed3..63a4a37 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ Currently we can * pass options to the JSON decoder used by Elastix ([poison](https://github.com/devinus/poison)) * optionally use shield for authentication ([shield](https://www.elastic.co/products/shield)) * optionally pass along custom headers for every request made to the elasticsearch server(s)s + * optionally pass along options to [HTTPoison](https://github.com/edgurgel/httpoison) by setting the respective keys in your `config/config.exs` @@ -137,7 +138,8 @@ config :elastix, poison_options: [keys: :atoms], shield: true, username: "username", - password: "password" + password: "password", + httpoison_options: [hackney: [pool: :elastix_pool]] ``` The above for example will