Skip to content

Commit 13856f6

Browse files
committed
Add support for overriding host
1 parent bfd11ed commit 13856f6

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

priv/post.erl.eex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}) ->
6767
handle_response({error, Reason}) ->
6868
{error, Reason}.
6969

70+
build_host(_EndpointPrefix, #{host := Host}) when is_binary(Host) ->
71+
Host;
7072
build_host(_EndpointPrefix, #{region := <<"local">>}) ->
7173
<<"localhost">>;<%= if context.is_global do %>
7274
build_host(EndpointPrefix, #{endpoint := Endpoint}) ->

priv/post.ex.eex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ defmodule <%= context.module_name %> do
4949
end
5050
end
5151

52+
defp build_host(_endpoint_prefix, %{host: host}) when is_binary(host) do
53+
host
54+
end
5255
defp build_host(_endpoint_prefix, %{region: "local"}) do
5356
"localhost"
5457
end<%= if context.is_global do %>

priv/rest.erl.eex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}, _) ->
150150
{error, Error, {StatusCode, ResponseHeaders, Client}};
151151
handle_response({error, Reason}, _) ->
152152
{error, Reason}.
153+
build_host(_AccountId, _EndpointPrefix, #{host := Host}) when is_binary(Host) ->
154+
Host;
153155
<%= if context.endpoint_prefix == "s3-control" do %>
154156
build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>}) ->
155157
<<"localhost">>;

priv/rest.ex.eex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ defmodule <%= context.module_name %> do
133133
{:error, %HTTPoison.Error{reason: reason}}
134134
end
135135
end
136+
137+
defp build_host(_endpoint_prefix, %{host: host}) when is_binary(host) do
138+
host
139+
end
136140
<%= if context.endpoint_prefix == "s3-control" do %>
137141
defp build_host(_account_id, _endpoint_prefix, %{region: "local"}) do
138142
"localhost"

0 commit comments

Comments
 (0)