2019-07-10 07:13:23 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 23:44:49 +01:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-07-10 07:13:23 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-07-09 18:54:13 +02:00
|
|
|
defmodule Pleroma.ReverseProxy.Client do
|
|
|
|
@callback request(atom(), String.t(), [tuple()], String.t(), list()) ::
|
|
|
|
{:ok, pos_integer(), [tuple()], reference() | map()}
|
|
|
|
| {:ok, pos_integer(), [tuple()]}
|
|
|
|
| {:ok, reference()}
|
|
|
|
| {:error, term()}
|
|
|
|
|
|
|
|
@callback stream_body(reference() | pid() | map()) ::
|
|
|
|
{:ok, binary()} | :done | {:error, String.t()}
|
|
|
|
|
|
|
|
@callback close(reference() | pid() | map()) :: :ok
|
|
|
|
|
|
|
|
def request(method, url, headers, "", opts \\ []) do
|
|
|
|
client().request(method, url, headers, "", opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stream_body(ref), do: client().stream_body(ref)
|
|
|
|
|
|
|
|
def close(ref), do: client().close(ref)
|
|
|
|
|
|
|
|
defp client do
|
|
|
|
Pleroma.Config.get([Pleroma.ReverseProxy.Client], :hackney)
|
|
|
|
end
|
|
|
|
end
|