summaryrefslogtreecommitdiff
path: root/lib/pleroma/http/ex_aws.ex
blob: 5cac3532f7cfd899b64b1c038106a1d2ce36ab5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.HTTP.ExAws do
  @moduledoc false

  @behaviour ExAws.Request.HttpClient

  alias Pleroma.HTTP

  @impl true
  def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
    http_opts = Keyword.put_new(http_opts, :pool, :upload)

    case HTTP.request(method, url, body, headers, http_opts) do
      {:ok, env} ->
        {:ok, %{status_code: env.status, headers: env.headers, body: env.body}}

      {:error, reason} ->
        {:error, %{reason: reason}}
    end
  end
end