diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2010-05-04 02:01:00 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2010-05-04 02:01:00 +0000 |
commit | 33b3524268195a0798993690b54cead286da28fb (patch) | |
tree | 3522835f347d8671d44a9e9f966bd3fc4604699e /src/couchdb/couch_httpd_rewrite.erl | |
parent | c2ddcc5d1c5fcbe712031df19ecc12c781d8b613 (diff) |
use keysearch BIF to search ejson props. Closes COUCHDB-747
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@940708 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_rewrite.erl')
-rw-r--r-- | src/couchdb/couch_httpd_rewrite.erl | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl index dce5994f..1e2a532f 100644 --- a/src/couchdb/couch_httpd_rewrite.erl +++ b/src/couchdb/couch_httpd_rewrite.erl @@ -122,7 +122,7 @@ handle_rewrite_req(#httpd{ #doc{body={Props}} = DDoc, % get rules from ddoc - case proplists:get_value(<<"rewrites">>, Props) of + case couch_util:get_value(<<"rewrites">>, Props) of undefined -> couch_httpd:send_error(Req, 404, <<"rewrite_error">>, <<"Invalid path.">>); @@ -204,7 +204,7 @@ try_bind_path([Dispatch|Rest], Method, PathParts, QueryList) -> % QueryArgs1 Bindings2 = lists:foldl(fun({K, V}, Acc) -> K1 = to_atom(K), - KV = case proplists:get_value(K1, QueryArgs1) of + KV = case couch_util:get_value(K1, QueryArgs1) of undefined -> [{K1, V}]; _V1 -> [] end, @@ -269,7 +269,7 @@ replace_var(Key, Value, Bindings) -> get_var(VarName, Props, Default) -> VarName1 = list_to_atom(binary_to_list(VarName)), - proplists:get_value(VarName1, Props, Default). + couch_util:get_value(VarName1, Props, Default). %% doc: build new patch from bindings. bindings are query args %% (+ dynamic query rewritten if needed) and bindings found in @@ -283,7 +283,7 @@ make_new_path([?MATCH_ALL|_Rest], _Bindings, Remaining, Acc) -> Acc1 = lists:reverse(Acc) ++ Remaining, Acc1; make_new_path([P|Rest], Bindings, Remaining, Acc) when is_atom(P) -> - P2 = case proplists:get_value(P, Bindings) of + P2 = case couch_util:get_value(P, Bindings) of undefined -> << "undefined">>; P1 -> P1 end, @@ -343,20 +343,20 @@ normalize_path1([Path|Rest], Acc) -> %% @doc transform json rule in erlang for pattern matching make_rule(Rule) -> - Method = case proplists:get_value(<<"method">>, Rule) of + Method = case couch_util:get_value(<<"method">>, Rule) of undefined -> '*'; M -> list_to_atom(?b2l(M)) end, - QueryArgs = case proplists:get_value(<<"query">>, Rule) of + QueryArgs = case couch_util:get_value(<<"query">>, Rule) of undefined -> []; {Args} -> Args end, - FromParts = case proplists:get_value(<<"from">>, Rule) of + FromParts = case couch_util:get_value(<<"from">>, Rule) of undefined -> ['*']; From -> parse_path(From) end, - ToParts = case proplists:get_value(<<"to">>, Rule) of + ToParts = case couch_util:get_value(<<"to">>, Rule) of undefined -> throw({error, invalid_rewrite_target}); To -> |