From e5be78e42c38b5546d68d98e4b1db286600e9ed5 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Wed, 22 Apr 2009 14:41:47 +0000 Subject: Refactoring the view URL parameter parsing. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@767543 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_show.erl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/couchdb/couch_httpd_show.erl') diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl index 21611262..c38522df 100644 --- a/src/couchdb/couch_httpd_show.erl +++ b/src/couchdb/couch_httpd_show.erl @@ -90,22 +90,26 @@ get_nested_json_value(_NotJSONObj, _) -> throw({not_found, json_mismatch}). send_view_list_response(Lang, ListSrc, ViewName, DesignId, Req, Db, Keys) -> - #view_query_args{ - stale = Stale, - reduce = Reduce - } = QueryArgs = couch_httpd_view:parse_view_query(Req, nil, nil, true), + Stale = couch_httpd_view:get_stale_type(Req), + Reduce = couch_httpd_view:get_reduce_type(Req), case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of {ok, View, Group} -> + QueryArgs = couch_httpd_view:parse_view_params(Req, Keys, map, ignore), output_map_list(Req, Lang, ListSrc, View, Group, Db, QueryArgs, Keys); {not_found, _Reason} -> case couch_view:get_reduce_view(Db, DesignId, ViewName, Stale) of {ok, ReduceView, Group} -> - couch_httpd_view:parse_view_query(Req, Keys, true, true), % just for validation case Reduce of false -> + QueryArgs = couch_httpd_view:parse_view_params( + Req, Keys, map_red, ignore + ), MapView = couch_view:extract_map_view(ReduceView), output_map_list(Req, Lang, ListSrc, MapView, Group, Db, QueryArgs, Keys); _ -> + QueryArgs = couch_httpd_view:parse_view_params( + Req, Keys, reduce, ignore + ), output_reduce_list(Req, Lang, ListSrc, ReduceView, Group, Db, QueryArgs, Keys) end; {not_found, Reason} -> @@ -429,4 +433,4 @@ apply_etag({ExternalResponse}, CurrentEtag) -> Field end || Field <- ExternalResponse]} end. - \ No newline at end of file + -- cgit v1.2.3