Skip to content

Commit df80b56

Browse files
authored
Merge pull request #48 from bolmar/local-endpoint
Allow overriding localhost as the endpoint for a local client
2 parents bfd11ed + 7df816c commit df80b56

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-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, #{region := <<"local">>, endpoint := Endpoint}) ->
71+
Endpoint;
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, %{region: "local", endpoint: endpoint}) do
53+
endpoint
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,17 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}, _) ->
151151
handle_response({error, Reason}, _) ->
152152
{error, Reason}.
153153
<%= if context.endpoint_prefix == "s3-control" do %>
154+
build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
155+
Endpoint;
154156
build_host(_AccountId, _EndpointPrefix, #{region := <<"local">>}) ->
155157
<<"localhost">>;
156158
build_host(undefined, _EndpointPrefix, _Client) ->
157159
error(missing_account_id);
158160
build_host(AccountId, EndpointPrefix, #{region := Region, endpoint := Endpoint}) ->
159161
aws_util:binary_join([AccountId, EndpointPrefix, Region, Endpoint],
160162
<<".">>).<% else %>
163+
build_host(_EndpointPrefix, #{region := <<"local">>, endpoint := Endpoint}) ->
164+
Endpoint;
161165
build_host(_EndpointPrefix, #{region := <<"local">>}) ->
162166
<<"localhost">>;<%= if context.is_global do %>
163167
build_host(EndpointPrefix, #{endpoint := Endpoint}) ->

priv/rest.ex.eex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ defmodule <%= context.module_name %> do
134134
end
135135
end
136136
<%= if context.endpoint_prefix == "s3-control" do %>
137+
defp build_host(_account_id, _endpoint_prefix, %{region: "local", endpoint: endpoint}) do
138+
endpoint
139+
end
137140
defp build_host(_account_id, _endpoint_prefix, %{region: "local"}) do
138141
"localhost"
139142
end
@@ -144,6 +147,9 @@ defmodule <%= context.module_name %> do
144147
"#{account_id}.#{endpoint_prefix}.#{region}.#{endpoint}"
145148
end
146149
<% else %>
150+
defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do
151+
endpoint
152+
end
147153
defp build_host(_endpoint_prefix, %{region: "local"}) do
148154
"localhost"
149155
end<%= if context.is_global do %>

0 commit comments

Comments
 (0)