diff options
author | Paul Joseph Davis <davisp@apache.org> | 2010-11-10 19:44:05 +0000 |
---|---|---|
committer | Paul Joseph Davis <davisp@apache.org> | 2010-11-10 19:44:05 +0000 |
commit | 9e53f467f89bc3942f8795f6d07f61d3f5115f88 (patch) | |
tree | 8480eaf7c98101322fc3b5fc00891685082fc944 /src/couchdb/couch_httpd.erl | |
parent | 1f7e7cb5c22302788e232ce455fd0505f6420201 (diff) |
Support the keys parameter in GET requests.
You can now request a list of keys in the query string using a query
string like:
?keys=["foo", "bar"]
Your query string obviously needs to be properly escaped.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1033676 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index e1f6fc28..dea41eeb 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -15,7 +15,8 @@ -export([start_link/0, start_link/1, stop/0, handle_request/5]). --export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]). +-export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,qs_json_value/3]). +-export([path/1,absolute_uri/2,body_length/1]). -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]). -export([make_fun_spec_strs/1]). -export([make_arity_1_fun/1, make_arity_2_fun/1, make_arity_3_fun/1]). @@ -384,6 +385,14 @@ qs_value(Req, Key) -> qs_value(Req, Key, Default) -> couch_util:get_value(Key, qs(Req), Default). +qs_json_value(Req, Key, Default) -> + case qs_value(Req, Key, Default) of + Default -> + Default; + Result -> + ?JSON_DECODE(Result) + end. + qs(#httpd{mochi_req=MochiReq}) -> MochiReq:parse_qs(). |