diff --git a/priv/post.erl.eex b/priv/post.erl.eex index 8adb44a..91ca73e 100644 --- a/priv/post.erl.eex +++ b/priv/post.erl.eex @@ -67,6 +67,8 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}) -> handle_response({error, Reason}) -> {error, Reason}. +build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) -> + Endpoint; build_host(_EndpointPrefix, #{region := <<"local">>}) -> <<"localhost">>;<%= if context.is_global do %> build_host(EndpointPrefix, #{endpoint := Endpoint}) -> diff --git a/priv/post.ex.eex b/priv/post.ex.eex index 332884c..8c6a0f8 100644 --- a/priv/post.ex.eex +++ b/priv/post.ex.eex @@ -49,6 +49,9 @@ defmodule <%= context.module_name %> do end end + defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do + endpoint + end defp build_host(_endpoint_prefix, %{region: "local"}) do "localhost" end<%= if context.is_global do %> diff --git a/priv/rest.erl.eex b/priv/rest.erl.eex index f4f2a1e..3aebea0 100644 --- a/priv/rest.erl.eex +++ b/priv/rest.erl.eex @@ -151,6 +151,8 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}, _) -> handle_response({error, Reason}, _) -> {error, Reason}. <%= if context.endpoint_prefix == "s3-control" do %> +build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) -> + Endpoint; build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>}) -> <<"localhost">>; build_host(undefined, _EndpointPrefix, _Client) -> @@ -158,6 +160,8 @@ build_host(undefined, _EndpointPrefix, _Client) -> build_host(AccountId, EndpointPrefix, #{region := Region, endpoint := Endpoint}) -> aws_util:binary_join([AccountId, EndpointPrefix, Region, Endpoint], <<".">>).<% else %> +build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) -> + Endpoint; build_host(_EndpointPrefix, #{region := <<"local">>}) -> <<"localhost">>;<%= if context.is_global do %> build_host(EndpointPrefix, #{endpoint := Endpoint}) -> diff --git a/priv/rest.ex.eex b/priv/rest.ex.eex index f83cb72..8fc86cf 100644 --- a/priv/rest.ex.eex +++ b/priv/rest.ex.eex @@ -134,6 +134,9 @@ defmodule <%= context.module_name %> do end end <%= if context.endpoint_prefix == "s3-control" do %> + defp build_host(_account_id, _endpoint_prefix, %{region: "local", endpoint: endpoint}) do + endpoint + end defp build_host(_account_id, _endpoint_prefix, %{region: "local"}) do "localhost" end @@ -144,6 +147,9 @@ defmodule <%= context.module_name %> do "#{account_id}.#{endpoint_prefix}.#{region}.#{endpoint}" end <% else %> + defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do + endpoint + end defp build_host(_endpoint_prefix, %{region: "local"}) do "localhost" end<%= if context.is_global do %>