summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2019-10-01 15:59:01 +0000
committerILYA Khlopotov <iilyak@apache.org>2019-10-01 15:59:01 +0000
commitfd9331ce1fb9bdc9def784172901a927f2f68c5c (patch)
tree3c0c5dcb4a535a205515a12fbae654a0becf4c61
parentf4def40cdeb4d2b01083366c3cb03b0dfe622978 (diff)
downloadcouchdb-fd9331ce1fb9bdc9def784172901a927f2f68c5c.tar.gz
Add helper functions to work with contexts
-rw-r--r--src/chttpd/src/chttpd.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index 704e203ce..e00088dd5 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -44,7 +44,9 @@
-export([
chunked_response_buffer_size/0,
- close_delayed_json_object/4
+ close_delayed_json_object/4,
+ contexts_to_list/1,
+ set_contexts/2
]).
-record(delayed_resp, {
@@ -1237,6 +1239,14 @@ span_ok(_Resp) ->
span_error(_ErrorStr, _ReasonStr, []) ->
fun(Span) -> Span end.
+contexts_to_list(Req) ->
+ set_contexts(Req, []).
+
+set_contexts(#httpd{user_ctx=UserCtx, request_ctx=RequestCtx}, KVList0) ->
+ KVList1 = lists:keystore(request_ctx, 1, KVList0, {request_ctx, RequestCtx}),
+ KVList2 = lists:keystore(user_ctx, 1, KVList1, {user_ctx, UserCtx}),
+ KVList2.
+
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").