Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
903B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.ReverseProxy.Client.Wrapper do
  5. @moduledoc "Meta-client that calls the appropriate client from the config."
  6. @behaviour Pleroma.ReverseProxy.Client
  7. @impl true
  8. def request(method, url, headers, body \\ "", opts \\ []) do
  9. client().request(method, url, headers, body, opts)
  10. end
  11. @impl true
  12. def stream_body(ref), do: client().stream_body(ref)
  13. @impl true
  14. def close(ref), do: client().close(ref)
  15. defp client do
  16. :tesla
  17. |> Application.get_env(:adapter)
  18. |> client()
  19. end
  20. defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
  21. defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
  22. defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
  23. end