add license boilerplate to pleroma core
[akkoma] / lib / pleroma / http / connection.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.HTTP.Connection do
6 @moduledoc """
7 Connection for http-requests.
8 """
9
10 @hackney_options [
11 pool: :default,
12 timeout: 10000,
13 recv_timeout: 20000,
14 follow_redirect: true
15 ]
16 @adapter Application.get_env(:tesla, :adapter)
17
18 @doc """
19 Configure a client connection
20
21 # Returns
22
23 Tesla.Env.client
24 """
25 @spec new(Keyword.t()) :: Tesla.Env.client()
26 def new(opts \\ []) do
27 Tesla.client([], {@adapter, hackney_options(opts)})
28 end
29
30 # fetch Hackney options
31 #
32 defp hackney_options(opts) do
33 options = Keyword.get(opts, :adapter, [])
34 @hackney_options ++ options
35 end
36 end