You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2018/08/30 09:34:38 UTC
[couchdb] 02/02: add POST support for keys for views
This is an automated email from the ASF dual-hosted git repository.
garren pushed a commit to branch partition-add-post
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a3a105ccbec3332edc6955579e6a1e14b5c4c427
Author: Garren Smith <ga...@gmail.com>
AuthorDate: Thu Aug 30 11:34:20 2018 +0200
add POST support for keys for views
---
src/chttpd/src/chttpd_view.erl | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl
index 627663c..557f2b6 100644
--- a/src/chttpd/src/chttpd_view.erl
+++ b/src/chttpd/src/chttpd_view.erl
@@ -106,6 +106,25 @@ handle_temp_view_req(Req, _Db) ->
chttpd:send_error(Req, 410, gone, Msg).
+handle_partition_view_req(#httpd{method='POST',
+ path_parts=[_, _, _, _, _, _, ViewName]} = Req, Db, DDoc, Partition) ->
+ chttpd:validate_ctype(Req, "application/json"),
+ Props = couch_httpd:json_body_obj(Req),
+ Keys = couch_mrview_util:get_view_keys(Props),
+ case Keys of
+ Keys when is_list(Keys) ->
+ couch_stats:increment_counter([couchdb, httpd, view_reads]),
+ Args = couch_mrview_http:parse_params(Req, Keys),
+ Args1 = couch_mrview_util:set_extra(Args, partition, Partition),
+ Args2 = couch_mrview_util:set_extra(Args1, partitioned, true),
+ design_doc_view_int(Req, Db, DDoc, ViewName, Args2);
+ _ ->
+ throw({
+ bad_request,
+ "POST body must contain `keys` field"
+ })
+ end;
+
handle_partition_view_req(#httpd{method='GET',
path_parts=[_, _, _, _, _, _, ViewName]} = Req, Db, DDoc, Partition) ->
Keys = chttpd:qs_json_value(Req, "keys", undefined),