summaryrefslogtreecommitdiff
path: root/lib/powerdnsex/http_client.ex
blob: 26bc6b5358b8c1d61006cd7db6201bed98d70aec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
defmodule PowerDNSex.HttpClient do
  @moduledoc """
  Client to do http requests for PowerDns API
  """

  use HTTPoison.Base

  alias PowerDNSex.Config

  def process_url("/"<>url), do: process_url(url)

  def process_url(url) do
    Config.powerdns_url() <> url
  end

  def process_request_headers(headers) do
    custom = ["X-API-Key": Config.powerdns_token()]
    Keyword.merge(headers, custom)
  end

  def process_request_options(options) do
    custom_options = [ssl: [{:versions, [:"tlsv1.1"]}], recv_timeout: Config.powerdns_timeout()]
    Keyword.merge(options, custom_options)
  end
end