aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/http/connection.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/http/connection.ex')
-rw-r--r--lib/pleroma/http/connection.ex27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex
new file mode 100644
index 000000000..5e8f2aabd
--- /dev/null
+++ b/lib/pleroma/http/connection.ex
@@ -0,0 +1,27 @@
+defmodule Pleroma.HTTP.Connection do
+ @moduledoc """
+ Connection for http-requests.
+ """
+
+ @hackney_options [pool: :default]
+ @adapter Application.get_env(:tesla, :adapter)
+
+ @doc """
+ Configure a client connection
+
+ # Returns
+
+ Tesla.Env.client
+ """
+ @spec new(Keyword.t()) :: Tesla.Env.client()
+ def new(opts \\ []) do
+ Tesla.client([], {@adapter, hackney_options(opts)})
+ end
+
+ # fetch Hackney options
+ #
+ defp hackney_options(opts \\ []) do
+ options = Keyword.get(opts, :adapter, [])
+ @hackney_options ++ options
+ end
+end