Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Req request backend #1065

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/ex_aws/request/req.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule ExAws.Request.Req do
@behaviour ExAws.Request.HttpClient

@moduledoc """
Configuration for `m:Req`.

Options can be set for `m:Req` with the following config:

config :ex_aws, :req_opts,
receive_timeout: 30_000

The default config handles setting the above.
"""

@default_opts [receive_timeout: 30_000]

@impl true
def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
[method: method, url: url, body: body, headers: headers, decode_body: false]
|> Keyword.merge(Application.get_env(:ex_aws, :req_opts, @default_opts))
|> Keyword.merge(http_opts)
|> Req.request()
|> case do
{:ok, %{status: status, headers: headers, body: body}} ->
{:ok, %{status_code: status, headers: headers, body: body}}

{:error, reason} ->
{:error, %{reason: reason}}
end
end
end
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ defmodule ExAws.Mixfile do
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.16", only: [:dev, :test]},
{:hackney, "~> 1.16", optional: true},
{:req, "~> 0.3", optional: true},
{:jason, "~> 1.1", optional: true},
{:jsx, "~> 2.8 or ~> 3.0", optional: true},
{:mox, "~> 1.0", only: :test},
{:sweet_xml, "~> 0.7", optional: true},
{:excoveralls, "~> 0.10", only: :test},
{:req, "~> 0.3", only: :test}
{:excoveralls, "~> 0.10", only: :test}
]
end

Expand Down