From a647b35c1742ed221f88d1f24a4da79dfb19166c Mon Sep 17 00:00:00 2001 From: Alexey Lebedeff Date: Fri, 24 Mar 2017 11:29:12 +0300 Subject: Add ability to skip sorting of results Allow user to specify empty sort parameter to avoid paying the sorting cost. As for some applications (like monitoring) it doesn't matter whether the result is sorted at all. And e.g. for 10000 queues performing the sort using the default sorting order costs ~0.3 second on my machine. --- deps/rabbitmq_management/src/rabbit_mgmt_util.erl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'deps/rabbitmq_management') diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl index 537d9615a8..22caf8d915 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl @@ -255,6 +255,11 @@ reply_list_or_paginate(Facts, ReqData, Context) -> sort_list(Facts, Sorts) -> sort_list(Facts, Sorts, undefined, false, undefined). +sort_list(Facts, _, [], _, _) -> + %% Do not sort when we are explicitly requsted to sort with an + %% empty sort columns list. Note that this clause won't match when + %% 'sort' parameter is not provided in a HTTP request at all. + Facts; sort_list(Facts, DefaultSorts, Sort, Reverse, Pagination) -> SortList = case Sort of undefined -> DefaultSorts; -- cgit v1.2.1 From d61078d6d6036c21508806d91bf72ce32355ee4e Mon Sep 17 00:00:00 2001 From: Alexey Lebedeff Date: Thu, 23 Mar 2017 19:16:57 +0300 Subject: Add support for non-JSON encoding of replies One of the low-hanging fruits in HTTP API optimization. E.g. serializing information about 10000 queues: - For JSON it takes 2 seconds on my machine and more than 1GB of RAM - For BERT it takes 0.2 seconds and negligible amount of RAM --- deps/rabbitmq_management/src/rabbit_mgmt_util.erl | 22 +++++++++++++++++++--- .../src/rabbit_mgmt_wm_aliveness_test.erl | 2 +- .../src/rabbit_mgmt_wm_binding.erl | 2 +- .../src/rabbit_mgmt_wm_bindings.erl | 2 +- .../src/rabbit_mgmt_wm_channel.erl | 2 +- .../src/rabbit_mgmt_wm_channels.erl | 2 +- .../src/rabbit_mgmt_wm_channels_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_cluster_name.erl | 2 +- .../src/rabbit_mgmt_wm_connection.erl | 2 +- .../src/rabbit_mgmt_wm_connection_channels.erl | 2 +- .../src/rabbit_mgmt_wm_connections.erl | 2 +- .../src/rabbit_mgmt_wm_connections_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_consumers.erl | 2 +- .../src/rabbit_mgmt_wm_definitions.erl | 2 +- .../src/rabbit_mgmt_wm_exchange.erl | 2 +- .../src/rabbit_mgmt_wm_exchange_publish.erl | 2 +- .../src/rabbit_mgmt_wm_exchanges.erl | 2 +- .../src/rabbit_mgmt_wm_extensions.erl | 2 +- .../src/rabbit_mgmt_wm_global_parameter.erl | 2 +- .../src/rabbit_mgmt_wm_global_parameters.erl | 4 ++-- .../src/rabbit_mgmt_wm_healthchecks.erl | 2 +- .../src/rabbit_mgmt_wm_node.erl | 2 +- .../src/rabbit_mgmt_wm_node_memory.erl | 2 +- .../src/rabbit_mgmt_wm_node_memory_ets.erl | 2 +- .../src/rabbit_mgmt_wm_nodes.erl | 2 +- .../src/rabbit_mgmt_wm_overview.erl | 2 +- .../src/rabbit_mgmt_wm_parameter.erl | 2 +- .../src/rabbit_mgmt_wm_parameters.erl | 2 +- .../src/rabbit_mgmt_wm_permission.erl | 2 +- .../src/rabbit_mgmt_wm_permissions.erl | 2 +- .../src/rabbit_mgmt_wm_permissions_user.erl | 2 +- .../src/rabbit_mgmt_wm_permissions_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_policies.erl | 2 +- .../src/rabbit_mgmt_wm_policy.erl | 2 +- .../src/rabbit_mgmt_wm_queue.erl | 2 +- .../src/rabbit_mgmt_wm_queue_get.erl | 2 +- .../src/rabbit_mgmt_wm_queues.erl | 2 +- .../src/rabbit_mgmt_wm_user.erl | 2 +- .../src/rabbit_mgmt_wm_users.erl | 2 +- .../src/rabbit_mgmt_wm_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_vhosts.erl | 2 +- .../src/rabbit_mgmt_wm_whoami.erl | 2 +- .../test/rabbit_mgmt_http_SUITE.erl | 2 +- 43 files changed, 62 insertions(+), 46 deletions(-) (limited to 'deps/rabbitmq_management') diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl index 537d9615a8..4d1481e9d4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl @@ -28,7 +28,8 @@ -export([with_decode/4, not_found/3, amqp_request/4]). -export([with_channel/4, with_channel/5]). -export([props_to_method/2, props_to_method/4]). --export([all_or_one_vhost/2, http_to_amqp/5, reply/3, filter_vhost/3]). +-export([all_or_one_vhost/2, http_to_amqp/5, reply/3, json_like_handlers/1, + filter_vhost/3]). -export([filter_conn_ch_list/3, filter_user/2, list_login_vhosts/2]). -export([with_decode/5, decode/1, decode/2, set_resp_header/3, args/1]). @@ -193,14 +194,29 @@ destination_type(ReqData) -> <<"q">> -> queue end. +%% Prepares a list of Content-Types that are supported by +%% reply/3. This list can be used in content_types_provided/2 callback +%% of module implementing cowboy_rest. FunctionName/2 should be +%% exported from this module and this function should use reply/3 +%% under the hood. +json_like_handlers(FunctionName) -> + [{<<"application/json">>, FunctionName} + ,{<<"application/bert">>, FunctionName} + ]. + reply(Facts, ReqData, Context) -> reply0(extract_columns(Facts, ReqData), ReqData, Context). reply0(Facts, ReqData, Context) -> ReqData1 = set_resp_header(<<"Cache-Control">>, "no-cache", ReqData), try - {mochijson2:encode(rabbit_mgmt_format:format_nulls(Facts)), ReqData1, - Context} + case cowboy_req:meta(media_type, ReqData1) of + {{<<"application">>, <<"bert">>, _}, _} -> + {term_to_binary(Facts), ReqData1, Context}; + _ -> + {mochijson2:encode(rabbit_mgmt_format:format_nulls(Facts)), ReqData1, + Context} + end catch exit:{json_encode, E} -> Error = iolist_to_binary( io_lib:format("JSON encode error: ~p", [E])), diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl index 582d906619..af250bd9ac 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_util:vhost(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl index 4a8f9d8239..f233751541 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl index 5ffe5b30ad..8e5c05f5fa 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. %% The current version of Cowboy forces us to report the resource doesn't %% exist here in order to get a 201 response. It seems Cowboy confuses the diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl index 767b27b29f..ab6e27d0a9 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> case channel(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl index 5a527a142b..43d9e33df8 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl index 785e3c2ad4..e88181eb57 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_util:id(vhost, ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl index 91eebd1523..585d4a60d3 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl index dae913965a..bbfdb8e26c 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. allowed_methods(ReqData, Context) -> {[<<"HEAD">>, <<"GET">>, <<"DELETE">>, <<"OPTIONS">>], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl index dc5fd6f16c..6c5dc7498e 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> case rabbit_mgmt_wm_connection:conn(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl index c5d82e378a..e3ec094c87 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl index 5437023d69..06b36193f8 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_util:id(vhost, ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl index 9735a3cb7e..51f3499266 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_util:vhost(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl index 83eab8188d..750f241dd4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl @@ -40,7 +40,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{<<"application/json">>, accept_json}, diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl index 215e9f2499..b1e4e46996 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl index a6b31fbcdf..e9442a8acf 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl @@ -38,7 +38,7 @@ allowed_methods(ReqData, Context) -> {[<<"POST">>, <<"OPTIONS">>], ReqData, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_exchange:exchange(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl index 70ec59f81d..02b6f787a5 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case exchanges0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl index f3202d1a2d..7ef60089d0 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> Modules = rabbit_mgmt_dispatcher:modules([]), diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl index 4920cb0294..d208007915 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl @@ -37,7 +37,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl index 287ff917c9..ffb8860217 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(basic(), ReqData, Context). @@ -44,4 +44,4 @@ is_authorized(ReqData, Context) -> %%-------------------------------------------------------------------- basic() -> - rabbit_runtime_parameters:list_global(). \ No newline at end of file + rabbit_runtime_parameters:list_global(). diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl index 97186dd5c3..1819d96a55 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl @@ -32,7 +32,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case node0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl index 17d72d743e..3036e193c2 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case node0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl index 673b16234d..6f99d8d7b0 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {node_exists(ReqData, get_node(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl index 1363de7c83..bc5d03c09f 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {node_exists(ReqData, get_node(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl index 7e13c4a65d..3f0366b088 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl index e0419efc3a..14c955c8c0 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context = #context{user = User = #user{tags = Tags}}) -> RatesMode = rabbit_mgmt_agent_config:get_env(rates_mode), diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl index adbfe98338..d80a7451fd 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl index 6fe29283ea..9470258474 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case basic(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl index a2f174f620..613695e21f 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl index 49fa613575..9268cd5ba9 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(permissions(), ["vhost", "user"], diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl index 8bce98f02d..1dc35a6b04 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_user:user(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl index b113a2d26a..e88a9e9c95 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_wm_vhost:id(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl index 1dedcf5c9d..b7717a570c 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case basic(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl index 9f9c53f9e6..19ceafb146 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl index 93f80e8580..3d66d501b2 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl index f4a221baab..9d24741666 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl @@ -38,7 +38,7 @@ allowed_methods(ReqData, Context) -> {[<<"POST">>, <<"OPTIONS">>], ReqData, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_queue:queue(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl index 9348266bc0..9a3b3a4095 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case queues0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl index 213f8e2746..8b39b50c25 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl index 7bff83ee9b..6413a695a4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(users(), ReqData, Context). diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl index 809c2f23ff..7cb57cf6c2 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl index 37fd120596..91d78361e0 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl index 876cbbb676..486ed74a4b 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {[{<<"application/json">>, to_json}], ReqData, Context}. + {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. to_json(ReqData, Context = #context{user = User}) -> rabbit_mgmt_util:reply(rabbit_mgmt_format:user(User), ReqData, Context). diff --git a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl index 05c41319dd..b5912f3721 100644 --- a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl +++ b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl @@ -2085,7 +2085,7 @@ cors_test(Config) -> {ok, {_, HdNoCORS, _}} = req(Config, get, "/overview", [auth_header("guest", "guest")]), false = lists:keymember("access-control-allow-origin", 1, HdNoCORS), %% The Vary header should include "Origin" regardless of CORS configuration. - {_, "accept-encoding, origin"} = lists:keyfind("vary", 1, HdNoCORS), + {_, "accept, accept-encoding, origin"} = lists:keyfind("vary", 1, HdNoCORS), %% Enable CORS. rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, [rabbitmq_management, cors_allow_origins, ["http://rabbitmq.com"]]), %% We should only receive allow-origin and allow-credentials from GET. -- cgit v1.2.1 From f70e0193c494e515ead833c646c27104f06f3c54 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 24 Mar 2017 14:41:33 +0300 Subject: Naming, correct a comment --- deps/rabbitmq_management/src/rabbit_mgmt_util.erl | 17 +++++++++-------- .../src/rabbit_mgmt_wm_aliveness_test.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl | 2 +- .../rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl | 2 +- .../rabbitmq_management/src/rabbit_mgmt_wm_channels.erl | 2 +- .../src/rabbit_mgmt_wm_channels_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_cluster_name.erl | 2 +- .../src/rabbit_mgmt_wm_connection.erl | 2 +- .../src/rabbit_mgmt_wm_connection_channels.erl | 2 +- .../src/rabbit_mgmt_wm_connections.erl | 2 +- .../src/rabbit_mgmt_wm_connections_vhost.erl | 2 +- .../src/rabbit_mgmt_wm_consumers.erl | 2 +- .../src/rabbit_mgmt_wm_definitions.erl | 2 +- .../rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl | 2 +- .../src/rabbit_mgmt_wm_exchange_publish.erl | 2 +- .../src/rabbit_mgmt_wm_exchanges.erl | 2 +- .../src/rabbit_mgmt_wm_extensions.erl | 2 +- .../src/rabbit_mgmt_wm_global_parameter.erl | 2 +- .../src/rabbit_mgmt_wm_global_parameters.erl | 2 +- .../src/rabbit_mgmt_wm_healthchecks.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl | 2 +- .../src/rabbit_mgmt_wm_node_memory.erl | 2 +- .../src/rabbit_mgmt_wm_node_memory_ets.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl | 2 +- .../rabbitmq_management/src/rabbit_mgmt_wm_overview.erl | 2 +- .../src/rabbit_mgmt_wm_parameter.erl | 2 +- .../src/rabbit_mgmt_wm_parameters.erl | 2 +- .../src/rabbit_mgmt_wm_permission.erl | 2 +- .../src/rabbit_mgmt_wm_permissions.erl | 2 +- .../src/rabbit_mgmt_wm_permissions_user.erl | 2 +- .../src/rabbit_mgmt_wm_permissions_vhost.erl | 2 +- .../rabbitmq_management/src/rabbit_mgmt_wm_policies.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl | 2 +- .../src/rabbit_mgmt_wm_queue_get.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl | 2 +- deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl | 2 +- 42 files changed, 50 insertions(+), 49 deletions(-) (limited to 'deps/rabbitmq_management') diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl index 4d1481e9d4..e4b6b95efb 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_util.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_util.erl @@ -28,7 +28,7 @@ -export([with_decode/4, not_found/3, amqp_request/4]). -export([with_channel/4, with_channel/5]). -export([props_to_method/2, props_to_method/4]). --export([all_or_one_vhost/2, http_to_amqp/5, reply/3, json_like_handlers/1, +-export([all_or_one_vhost/2, http_to_amqp/5, reply/3, responder_map/1, filter_vhost/3]). -export([filter_conn_ch_list/3, filter_user/2, list_login_vhosts/2]). -export([with_decode/5, decode/1, decode/2, set_resp_header/3, @@ -194,14 +194,15 @@ destination_type(ReqData) -> <<"q">> -> queue end. -%% Prepares a list of Content-Types that are supported by -%% reply/3. This list can be used in content_types_provided/2 callback -%% of module implementing cowboy_rest. FunctionName/2 should be -%% exported from this module and this function should use reply/3 +%% Provides a map of content type-to-responder that are supported by +%% reply/3. The map can be used in the content_types_provided/2 callback +%% used by cowboy_rest. Responder functions must be +%% exported from the caller module and must use reply/3 %% under the hood. -json_like_handlers(FunctionName) -> - [{<<"application/json">>, FunctionName} - ,{<<"application/bert">>, FunctionName} +responder_map(FunctionName) -> + [ + {<<"application/json">>, FunctionName} + , {<<"application/bert">>, FunctionName} ]. reply(Facts, ReqData, Context) -> diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl index af250bd9ac..f03eaf5589 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_util:vhost(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl index f233751541..481ebf589a 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_binding.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl index 8e5c05f5fa..719cf509b7 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_bindings.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. %% The current version of Cowboy forces us to report the resource doesn't %% exist here in order to get a 201 response. It seems Cowboy confuses the diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl index ab6e27d0a9..63d355d784 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channel.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> case channel(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl index 43d9e33df8..80ab49e417 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl index e88181eb57..985982b1c7 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_channels_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_util:id(vhost, ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl index 585d4a60d3..4668223ab5 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_cluster_name.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl index bbfdb8e26c..c3e67b03c9 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. allowed_methods(ReqData, Context) -> {[<<"HEAD">>, <<"GET">>, <<"DELETE">>, <<"OPTIONS">>], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl index 6c5dc7498e..4f59f3a365 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connection_channels.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> case rabbit_mgmt_wm_connection:conn(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl index e3ec094c87..8c68d14bea 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl index 06b36193f8..358c28ad4a 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_connections_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_util:id(vhost, ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl index 51f3499266..5c13f4e5a3 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_consumers.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_util:vhost(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl index 268e2c5dd7..8ff2af273f 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl @@ -40,7 +40,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{<<"application/json">>, accept_json}, diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl index b1e4e46996..55721e3c0f 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl index e9442a8acf..f9004b2303 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchange_publish.erl @@ -38,7 +38,7 @@ allowed_methods(ReqData, Context) -> {[<<"POST">>, <<"OPTIONS">>], ReqData, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_exchange:exchange(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl index 02b6f787a5..0d513d3940 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_exchanges.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case exchanges0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl index 7ef60089d0..4e1d70ad17 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_extensions.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> Modules = rabbit_mgmt_dispatcher:modules([]), diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl index d208007915..3d49057245 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameter.erl @@ -37,7 +37,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl index ffb8860217..4319c4a0c9 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_global_parameters.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(basic(), ReqData, Context). diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl index 5f43868d38..81c88f7627 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_healthchecks.erl @@ -32,7 +32,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case node0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl index 3036e193c2..16b5e0be4c 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case node0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl index 6f99d8d7b0..b134bfdf59 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {node_exists(ReqData, get_node(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl index bc5d03c09f..cf350c862d 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_node_memory_ets.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {node_exists(ReqData, get_node(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl index 3f0366b088..c2e791c018 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_nodes.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl index 14c955c8c0..5ad9b01e96 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_overview.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context = #context{user = User = #user{tags = Tags}}) -> RatesMode = rabbit_mgmt_agent_config:get_env(rates_mode), diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl index ca353da6aa..ab75bbe8f3 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameter.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl index 9470258474..bf7fe311d3 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_parameters.erl @@ -35,7 +35,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case basic(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl index 613695e21f..bfe1d49add 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permission.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl index 9268cd5ba9..4a8bf75d22 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(permissions(), ["vhost", "user"], diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl index 1dc35a6b04..a85ed7046e 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_user.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_user:user(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl index e88a9e9c95..515150e01b 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_permissions_vhost.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {rabbit_vhost:exists(rabbit_mgmt_wm_vhost:id(ReqData)), ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl index b7717a570c..99fbe6634d 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policies.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case basic(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl index 19ceafb146..0f17d469c4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_policy.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl index 3d66d501b2..48dc29a549 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl index 9d24741666..65b144c2eb 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl @@ -38,7 +38,7 @@ allowed_methods(ReqData, Context) -> {[<<"POST">>, <<"OPTIONS">>], ReqData, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case rabbit_mgmt_wm_queue:queue(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl index 9a3b3a4095..91e925eb0a 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. resource_exists(ReqData, Context) -> {case queues0(ReqData) of diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl index 8b39b50c25..8424adc8f4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_user.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl index 6413a695a4..2ca44bbc06 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_users.erl @@ -36,7 +36,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> rabbit_mgmt_util:reply_list(users(), ReqData, Context). diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl index 7cb57cf6c2..cb06a5b6f9 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhost.erl @@ -38,7 +38,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. content_types_accepted(ReqData, Context) -> {[{'*', accept_content}], ReqData, Context}. diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl index 91d78361e0..eee83de7ee 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_vhosts.erl @@ -34,7 +34,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context) -> try diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl index 486ed74a4b..d074c741a4 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_whoami.erl @@ -33,7 +33,7 @@ variances(Req, Context) -> {[<<"accept-encoding">>, <<"origin">>], Req, Context}. content_types_provided(ReqData, Context) -> - {rabbit_mgmt_util:json_like_handlers(to_json), ReqData, Context}. + {rabbit_mgmt_util:responder_map(to_json), ReqData, Context}. to_json(ReqData, Context = #context{user = User}) -> rabbit_mgmt_util:reply(rabbit_mgmt_format:user(User), ReqData, Context). -- cgit v1.2.1