couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [1/2] couch-mrview commit: updated refs/heads/master to c3bed46
Date Mon, 09 Nov 2015 23:40:28 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/master 1c8a3026b -> c3bed460e


Reduce duplicated code


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/c3bed460
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/c3bed460
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/c3bed460

Branch: refs/heads/master
Commit: c3bed460ee844175b8ce11081386be27f686d8ff
Parents: 0334f69
Author: Alexander Shorin <kxepal@apache.org>
Authored: Thu Oct 22 23:22:58 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Tue Nov 10 02:38:24 2015 +0300

----------------------------------------------------------------------
 src/couch_mrview_show.erl | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/c3bed460/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_show.erl b/src/couch_mrview_show.erl
index 3c38c71..5a01b84 100644
--- a/src/couch_mrview_show.erl
+++ b/src/couch_mrview_show.erl
@@ -322,21 +322,10 @@ apply_etag({ExternalResponse}, CurrentEtag) ->
     % headers on the JsonResponse object. We need to control the Etag and
     % Vary headers. If the external function controls the Etag, we'd have to
     % run it to check for a match, which sort of defeats the purpose.
-    case couch_util:get_value(<<"headers">>, ExternalResponse, nil) of
-    nil ->
-        % no JSON headers
-        % add our Etag and Vary headers to the response
-        {[{<<"headers">>, {[{<<"Etag">>, CurrentEtag}, {<<"Vary">>,
<<"Accept">>}]}} | ExternalResponse]};
-    JsonHeaders ->
-        {[case Field of
-        {<<"headers">>, JsonHeaders} -> % add our headers
-            JsonHeadersEtagged = json_apply_field({<<"Etag">>, CurrentEtag},
JsonHeaders),
-            JsonHeadersVaried = json_apply_field({<<"Vary">>, <<"Accept">>},
JsonHeadersEtagged),
-            {<<"headers">>, JsonHeadersVaried};
-        _ -> % skip non-header fields
-            Field
-        end || Field <- ExternalResponse]}
-    end.
+    apply_headers(ExternalResponse, [
+        {<<"Etag">>, CurrentEtag},
+        {<<"Vary">>, <<"Accept">>}
+    ]).
 
 apply_headers(JsonResp, []) ->
     JsonResp;


Mime
View raw message