2021-06-02 15:34:32 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-01 04:11:47 -07:00
|
|
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
2021-06-02 15:34:32 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.ReverseProxy.Client.Wrapper do
|
|
|
|
@moduledoc "Meta-client that calls the appropriate client from the config."
|
|
|
|
@behaviour Pleroma.ReverseProxy.Client
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def request(method, url, headers, body \\ "", opts \\ []) do
|
|
|
|
client().request(method, url, headers, body, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def stream_body(ref), do: client().stream_body(ref)
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def close(ref), do: client().close(ref)
|
|
|
|
|
|
|
|
defp client do
|
|
|
|
:tesla
|
|
|
|
|> Application.get_env(:adapter)
|
|
|
|
|> client()
|
|
|
|
end
|
|
|
|
|
|
|
|
defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
|
|
|
|
defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
|
2021-12-16 10:36:58 -07:00
|
|
|
defp client({Tesla.Adapter.Finch, _}), do: Pleroma.ReverseProxy.Client.Hackney
|
2021-06-02 15:34:32 -06:00
|
|
|
defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
|
|
|
|
end
|