summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-03-28 11:17:32 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-03-28 11:17:32 +0000
commit8fdcf154634d3b0efedd64049df8f4006a1415cc (patch)
tree3ed7f7e07eb16c38691950ad92ab854fb5809a92 /src
parent41680a4491aa018660a990997925b7a9ad3c82e4 (diff)
allows more complex keys in the rewriter, so it could ease the
pagination (only array for now) : { "from": "simpleForm/complexView5/:a/:b", "to": "_list/simpleForm/complexView3", "query": { "key": [":a", ":b"] } }, git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@928374 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd_rewrite.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl
index 73b15494..dce5994f 100644
--- a/src/couchdb/couch_httpd_rewrite.erl
+++ b/src/couchdb/couch_httpd_rewrite.erl
@@ -242,8 +242,18 @@ make_query_list([{Key, Value}|Rest], Bindings, Acc) ->
replace_var(Key, Value, Bindings) ->
case Value of
<<":", Var/binary>> ->
- Var1 = list_to_atom(binary_to_list(Var)),
- proplists:get_value(Var1, Bindings, Value);
+ get_var(Var, Bindings, Value);
+ _ when is_list(Value) ->
+ Value1 = lists:foldr(fun(V, Acc) ->
+ V1 = case V of
+ <<":", VName/binary>> ->
+ get_var(VName, Bindings, V);
+ _ ->
+ V
+ end,
+ [V1|Acc]
+ end, [], Value),
+ to_json(Value1);
_ when is_binary(Value) ->
Value;
_ ->
@@ -257,6 +267,10 @@ replace_var(Key, Value, Bindings) ->
end.
+get_var(VarName, Props, Default) ->
+ VarName1 = list_to_atom(binary_to_list(VarName)),
+ proplists:get_value(VarName1, Props, Default).
+
%% doc: build new patch from bindings. bindings are query args
%% (+ dynamic query rewritten if needed) and bindings found in
%% bind_path step.