Skip to content

Commit

Permalink
WHISTLE-617 set the etag
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Sep 22, 2011
1 parent 21f3228 commit 919a3ba
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions whistle_apps/apps/crossbar/src/crossbar_doc.erl
Expand Up @@ -527,19 +527,18 @@ is_private_key(_) -> false.
-spec(rev_to_etag/1 :: (Json :: json_object()|json_objects()) -> undefined | automatic | string()).
rev_to_etag([{struct, _}|_])->
automatic;
rev_to_etag({struct, Props}) ->
case props:get_value([<<"_rev">>], Props) of
Rev when is_list(Rev) ->
rev_to_etag(Rev);
_Else ->
undefined
rev_to_etag({struct, _}=JObj) ->
case wh_json:get_value(<<"_rev">>, JObj) of
undefined ->
undefined;
Rev ->
rev_to_etag(Rev)
end;
rev_to_etag([]) -> undefined;
rev_to_etag(Rev) when is_binary(Rev) ->
rev_to_etag(wh_util:to_list(Rev));
rev_to_etag(ETag) when is_list(ETag) ->
?LOG("Etag in rev to etag: ~p", [ETag]),
string:sub_string(ETag, 1, 2) ++ string:sub_string(ETag, 4);
rev_to_etag(Rev) when is_list(Rev) ->
Rev;
rev_to_etag(_Json) ->
?LOG("Unhandled JSON format in rev to etag: ~p", [_Json]),
undefined.
Expand Down

0 comments on commit 919a3ba

Please sign in to comment.