Skip to content

Commit

Permalink
Add support for overriding host
Browse files Browse the repository at this point in the history
  • Loading branch information
tfwright committed Oct 13, 2020
1 parent df80b56 commit 066341a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions priv/post.erl.eex
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ handle_response({error, Reason}) ->

build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
Endpoint;
build_host(_EndpointPrefix, #{host := Host}) when is_binary(Host) ->
Host;
build_host(_EndpointPrefix, #{region := <<"local">>}) ->
<<"localhost">>;<%= if context.is_global do %>
build_host(EndpointPrefix, #{endpoint := Endpoint}) ->
Expand Down
3 changes: 3 additions & 0 deletions priv/post.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ defmodule <%= context.module_name %> do
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
endpoint
end
defp build_host(_endpoint_prefix, %{host: host}) when is_binary(host) do
host
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end<%= if context.is_global do %>
Expand Down
2 changes: 2 additions & 0 deletions priv/rest.erl.eex
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}, _) ->
{error, Error, {StatusCode, ResponseHeaders, Client}};
handle_response({error, Reason}, _) ->
{error, Reason}.
build_host(_AccountId, _EndpointPrefix, #{host := Host}) when is_binary(Host) ->
Host;
<%= if context.endpoint_prefix == "s3-control" do %>
build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
Endpoint;
Expand Down
4 changes: 4 additions & 0 deletions priv/rest.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ defmodule <%= context.module_name %> do
{:error, %HTTPoison.Error{reason: reason}}
end
end

defp build_host(_endpoint_prefix, %{host: host}) when is_binary(host) do
host
end
<%= if context.endpoint_prefix == "s3-control" do %>
defp build_host(_account_id, _endpoint_prefix, %{region: "local", endpoint: endpoint}) do
endpoint
Expand Down

0 comments on commit 066341a

Please sign in to comment.