From fef167dd3fce5601abf633e38d42f10defb986d8 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Thu, 1 Dec 2011 11:08:53 -0800 Subject: [PATCH] WHISTLE-630: add get_Auth_realm to wapi_route --- lib/whistle-1.0.0/src/api/wapi_route.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/whistle-1.0.0/src/api/wapi_route.erl b/lib/whistle-1.0.0/src/api/wapi_route.erl index b4eeffc8c5f..64f27a5c887 100644 --- a/lib/whistle-1.0.0/src/api/wapi_route.erl +++ b/lib/whistle-1.0.0/src/api/wapi_route.erl @@ -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">> @@ -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.