Skip to content

Commit

Permalink
WHISTLE-630: add get_Auth_realm to wapi_route
Browse files Browse the repository at this point in the history
  • Loading branch information
James Aimonetti committed Dec 1, 2011
1 parent e3b084c commit fef167d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/whistle-1.0.0/src/api/wapi_route.erl
Expand Up @@ -18,6 +18,8 @@
,publish_win/2, publish_win/3
]).

-export([get_auth_realm/1]).

%% Route Requests
-define(ROUTE_REQ_HEADERS, [<<"Msg-ID">>, <<"To">>, <<"From">>, <<"Request">>, <<"Call-ID">>
,<<"Caller-ID-Name">>, <<"Caller-ID-Number">>
Expand Down Expand Up @@ -229,3 +231,15 @@ publish_win(RespQ, JObj) ->
publish_win(RespQ, Win, ContentType) ->
{ok, Payload} = wh_api:prepare_api_payload(Win, ?ROUTE_WIN_VALUES, fun win/1),
amqp_util:targeted_publish(RespQ, Payload, ContentType).

%%-----------------------------------------------------------------------------
%% @private
%% @doc
%% extract the auth realm from the API request, using the requests to domain
%% when provided with an IP
%% @end
%%-----------------------------------------------------------------------------
-spec get_auth_realm/1 :: (json_object()) -> ne_binary().
get_auth_realm(ApiJObj) ->
[_ReqUser, ReqDomain] = binary:split(wh_json:get_value(<<"Request">>, ApiJObj), <<"@">>),
ReqDomain.

0 comments on commit fef167d

Please sign in to comment.