connection.ex 552 Bytes
Newer Older
1
defmodule Pleroma.HTTP.Connection do
Maksim's avatar
Maksim committed
2
3
4
5
  @moduledoc """
  Connection for http-requests.
  """

6
  @hackney_options [pool: :default]
Maksim's avatar
Maksim committed
7
  @adapter Application.get_env(:tesla, :adapter)
8
9
10
11
12
13
14
15
16
17

  @doc """
  Configure a client connection

  # Returns

  Tesla.Env.client
  """
  @spec new(Keyword.t()) :: Tesla.Env.client()
  def new(opts \\ []) do
Maksim's avatar
Maksim committed
18
    Tesla.client([], {@adapter, hackney_options(opts)})
19
20
21
22
23
24
25
26
27
  end

  # fetch Hackney options
  #
  defp hackney_options(opts \\ []) do
    options = Keyword.get(opts, :adapter, [])
    @hackney_options ++ options
  end
end