Merge branch 'exclude-reblogs-from-admin-api-by-default' into 'develop'
[akkoma] / lib / pleroma / reverse_proxy / client.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.ReverseProxy.Client do
6 @callback request(atom(), String.t(), [tuple()], String.t(), list()) ::
7 {:ok, pos_integer(), [tuple()], reference() | map()}
8 | {:ok, pos_integer(), [tuple()]}
9 | {:ok, reference()}
10 | {:error, term()}
11
12 @callback stream_body(reference() | pid() | map()) ::
13 {:ok, binary()} | :done | {:error, String.t()}
14
15 @callback close(reference() | pid() | map()) :: :ok
16
17 def request(method, url, headers, "", opts \\ []) do
18 client().request(method, url, headers, "", opts)
19 end
20
21 def stream_body(ref), do: client().stream_body(ref)
22
23 def close(ref), do: client().close(ref)
24
25 defp client do
26 Pleroma.Config.get([Pleroma.ReverseProxy.Client], :hackney)
27 end
28 end