Skip to content

Commit

Permalink
Merge pull request dkataskin#37 from ariel-anieli/issue-27-get-host-a…
Browse files Browse the repository at this point in the history
…s-handle-call

get_host/3 exposed thru gen_server; PR for dkataskin#27
  • Loading branch information
dkataskin authored Dec 22, 2023
2 parents 297c123 + 5a6c14d commit c0b90d5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/erlazure.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
%% Table API
-export([list_tables/1, list_tables/3, new_table/2, delete_table/2]).

%% Host API
-export([get_host/3]).

%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

Expand Down Expand Up @@ -667,6 +670,12 @@ handle_call({new_table, TableName}, _From, State) ->
{Code, Body} = execute_request(ServiceContext, ReqContext1),
return_response(Code, Body, State, ?http_created, created);

% Get host
handle_call({get_host, Service, Domain}, _From, State) ->
Account = State#state.account,
Host = lists:concat([Account, ".", erlang:atom_to_list(Service), Domain]),
{reply, Host, State};

% Delete table
handle_call({delete_table, TableName}, _From, State) ->
ServiceContext = new_service_context(?table_service, State),
Expand Down Expand Up @@ -799,6 +808,10 @@ build_uri_base(Service, Account) ->

get_host(Service, Account) ->
lists:concat([Account, ".", erlang:atom_to_list(Service), ".core.windows.net"]).
get_host(Pid, Service, []) ->
gen_server:call(Pid, {get_host, Service, ".core.windows.net"});
get_host(Pid, Service, Domain) ->
gen_server:call(Pid, {get_host, Service, Domain}).

-spec canonicalize_headers([string()]) -> string().
canonicalize_headers(Headers) ->
Expand Down

0 comments on commit c0b90d5

Please sign in to comment.