diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-06-24 05:21:30 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-06-24 05:21:30 +0000 |
commit | 4b079e27429567b520abf091a8c0da84885c0d80 (patch) | |
tree | 7b75b92e6099b19b442dec35d198459f201da419 /src/couchdb/couch_util.erl | |
parent | a96cc93949fd8cf4bd91ce2fa49bb32b93a7de32 (diff) |
use JSON content type in replicator, require it in the _bulk_docs and other POST apis
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@957422 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_util.erl')
-rw-r--r-- | src/couchdb/couch_util.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index b334c961..e50ab2fe 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -19,6 +19,7 @@ -export([encodeBase64Url/1, decodeBase64Url/1]). -export([to_hex/1, parse_term/1, dict_find/3]). -export([file_read_size/1, get_nested_json_value/2, json_user_ctx/1]). +-export([proplist_apply_field/2, json_apply_field/2]). -export([to_binary/1, to_integer/1, to_list/1, url_encode/1]). -export([json_encode/1, json_decode/1]). -export([verify/2,simple_call/2,shutdown_sync/1]). @@ -143,6 +144,19 @@ get_nested_json_value(Value, []) -> get_nested_json_value(_NotJSONObj, _) -> throw({not_found, json_mismatch}). +proplist_apply_field(H, L) -> + {R} = json_apply_field(H, {L}), + R. + +json_apply_field(H, {L}) -> + json_apply_field(H, L, []). +json_apply_field({Key, NewValue}, [{Key, _OldVal} | Headers], Acc) -> + json_apply_field({Key, NewValue}, Headers, Acc); +json_apply_field({Key, NewValue}, [{OtherKey, OtherVal} | Headers], Acc) -> + json_apply_field({Key, NewValue}, Headers, [{OtherKey, OtherVal} | Acc]); +json_apply_field({Key, NewValue}, [], Acc) -> + {[{Key, NewValue}|Acc]}. + json_user_ctx(#db{name=DbName, user_ctx=Ctx}) -> {[{<<"db">>, DbName}, {<<"name">>,Ctx#user_ctx.name}, |