Skip to content

Commit 066341a

Browse files
committed
Add support for overriding host
1 parent df80b56 commit 066341a

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
@@ -69,6 +69,8 @@ handle_response({error, Reason}) ->
6969

7070
build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
7171
Endpoint;
72+
build_host(_EndpointPrefix, #{host := Host}) when is_binary(Host) ->
73+
Host;
7274
build_host(_EndpointPrefix, #{region := <<"local">>}) ->
7375
<<"localhost">>;<%= if context.is_global do %>
7476
build_host(EndpointPrefix, #{endpoint := Endpoint}) ->

priv/post.ex.eex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ defmodule <%= context.module_name %> do
5252
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
5353
endpoint
5454
end
55+
defp build_host(_endpoint_prefix, %{host: host}) when is_binary(host) do
56+
host
57+
end
5558
defp build_host(_endpoint_prefix, %{region: "local"}) do
5659
"localhost"
5760
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">>, endpoint := Endpoint}) ->
155157
Endpoint;

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", endpoint: endpoint}) do
138142
endpoint

0 commit comments

Comments
 (0)