Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
rabbitmq-management-visualiser
0001-Support-cowboy2.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Support-cowboy2.patch of Package rabbitmq-management-visualiser
From fa6ad61d7c59674a1bd65d28238f7a1de75c88be Mon Sep 17 00:00:00 2001 From: Daniil Fedotov <dfedotov@pivotal.io> Date: Mon, 23 Oct 2017 11:22:59 +0100 Subject: [PATCH] Support cowboy2 --- src/rabbit_mgmt_wm_all.erl | 9 ++- test/visualiser_http_SUITE.erl | 118 ++++++++++++++++----------------- 2 files changed, 63 insertions(+), 64 deletions(-) diff --git a/src/rabbit_mgmt_wm_all.erl b/src/rabbit_mgmt_wm_all.erl index 8119667..b449726 100644 --- a/src/rabbit_mgmt_wm_all.erl +++ b/src/rabbit_mgmt_wm_all.erl @@ -14,8 +14,8 @@ %% Copyright (c) 2007-2017 Pivotal Software, Inc. All rights reserved. -module(rabbit_mgmt_wm_all). --export([init/3]). --export([rest_init/2, to_json/2, content_types_provided/2, is_authorized/2, +-export([init/2]). +-export([to_json/2, content_types_provided/2, is_authorized/2, resource_exists/2]). -import(rabbit_misc, [pget/2]). @@ -24,9 +24,8 @@ -include_lib("amqp_client/include/amqp_client.hrl"). %%-------------------------------------------------------------------- -init(_, _, _) -> {upgrade, protocol, cowboy_rest}. - -rest_init(ReqData, _) -> {ok, ReqData, #context{}}. +init(Req, _State) -> + {cowboy_rest, rabbit_mgmt_cors:set_headers(Req, ?MODULE), #context{}}. content_types_provided(ReqData, Context) -> {[{<<"application/json">>, to_json}], ReqData, Context}. diff --git a/test/visualiser_http_SUITE.erl b/test/visualiser_http_SUITE.erl index 90ff735..05c495e 100644 --- a/test/visualiser_http_SUITE.erl +++ b/test/visualiser_http_SUITE.erl @@ -69,10 +69,10 @@ prepare_topology(Config) -> {<<"test_vhost2">>, <<"exchange_fanout">>, <<"fanout">>}], Bindings = [{<<"test_vhost1">>, <<"exchange_direct">>, <<"queue1">>, <<"rk">>, <<"rk">>}, {<<"test_vhost2">>, <<"exchange_fanout">>, <<"queue3">>, <<>>, <<$~>>}], - Topology = [{vhosts, Vhosts}, - {queues, top_queues(Queues)}, - {exchanges, top_exchanges(Vhosts, Exchanges)}, - {bindings, top_bindings(Queues, Bindings)}], + Topology = #{vhosts => Vhosts, + queues => top_queues(Queues), + exchanges => top_exchanges(Vhosts, Exchanges), + bindings => top_bindings(Queues, Bindings)}, create_vhosts(Config, Vhosts), create_queues(Config, Queues), create_exchanges(Config, Exchanges), @@ -81,7 +81,7 @@ prepare_topology(Config) -> drop_topology(Config) -> Topology = ?config(topology, Config), - Vhosts = proplists:get_value(vhosts, Topology), + Vhosts = maps:get(vhosts, Topology), drop_vhosts(Config, Vhosts), Config. @@ -120,48 +120,48 @@ drop_vhosts(Config, Vhosts) -> end, Vhosts). top_queues(Queues) -> - [ [{name, Queue}, - {vhost, Vhost}, - {durable, true}, - {auto_delete, false}, - {exclusive, false}, - {arguments, []}] || {Vhost, Queue} <- Queues ]. + [ #{name => Queue, + vhost => Vhost, + durable => true, + auto_delete => false, + exclusive => false, + arguments => #{}} || {Vhost, Queue} <- Queues ]. top_exchanges(Vhosts, Exchanges) -> default_exchanges(Vhosts) ++ - [[{name,Exchange}, - {vhost,Vhost}, - {type,Type}, - {durable,true}, - {auto_delete,false}, - {internal,false}, - {arguments,[]}] || {Vhost, Exchange, Type} <- Exchanges ]. + [#{name => Exchange, + vhost => Vhost, + type => Type, + durable => true, + auto_delete => false, + internal => false, + arguments => #{}} || {Vhost, Exchange, Type} <- Exchanges ]. default_exchanges(Vhosts) -> - [[{name,Exchange}, - {vhost,Vhost}, - {type,Type}, - {durable,true}, - {auto_delete,false}, - {internal,false}, - {arguments,[]}] + [#{name => Exchange, + vhost => Vhost, + type => Type, + durable => true, + auto_delete => false, + internal => false, + arguments => #{}} || {Exchange, Type} <- default_exchanges(), Vhost <- Vhosts] ++ - [[{name,<<"amq.rabbitmq.trace">>}, - {vhost,Vhost}, - {type,<<"topic">>}, - {durable,true}, - {auto_delete,false}, - {internal,true}, - {arguments,[]}] + [#{name => <<"amq.rabbitmq.trace">>, + vhost => Vhost, + type => <<"topic">>, + durable => true, + auto_delete => false, + internal => true, + arguments => #{}} || Vhost <- Vhosts ] ++ - [[{name,<<"amq.rabbitmq.log">>}, - {vhost,<<"/">>}, - {type,<<"topic">>}, - {durable,true}, - {auto_delete,false}, - {internal,true}, - {arguments,[]}]]. + [#{name => <<"amq.rabbitmq.log">>, + vhost => <<"/">>, + type => <<"topic">>, + durable => true, + auto_delete => false, + internal => true, + arguments => #{}}]. default_exchanges() -> [{<<>>, <<"direct">>}, @@ -173,31 +173,31 @@ default_exchanges() -> top_bindings(Queues, Bindings) -> default_bindings(Queues) ++ - [[{source,Exchange}, - {vhost,Vhost}, - {destination,Queue}, - {destination_type,<<"queue">>}, - {routing_key,RoutingKey}, - {arguments,[]}, - {properties_key,PropKey}] + [#{source => Exchange, + vhost => Vhost, + destination => Queue, + destination_type => <<"queue">>, + routing_key => RoutingKey, + arguments => #{}, + properties_key => PropKey} || {Vhost, Exchange, Queue, RoutingKey, PropKey} <- Bindings]. default_bindings(Queues) -> - [[{source,<<>>}, - {vhost,Vhost}, - {destination,Queue}, - {destination_type,<<"queue">>}, - {routing_key,Queue}, - {arguments,[]}, - {properties_key,Queue}] + [#{source => <<>>, + vhost => Vhost, + destination => Queue, + destination_type => <<"queue">>, + routing_key => Queue, + arguments => #{}, + properties_key => Queue} || {Vhost, Queue} <- Queues]. all_request(Config) -> Topology = ?config(topology, Config), All = http_get(Config, "/all"), - Queues = proplists:get_value(queues, All), - Exchanges = proplists:get_value(exchanges, All), - Bindings = proplists:get_value(bindings, All), - assert_list(proplists:get_value(queues, Topology), Queues), - assert_list(proplists:get_value(exchanges, Topology), Exchanges), - assert_list(proplists:get_value(bindings, Topology), Bindings). + Queues = maps:get(queues, All), + Exchanges = maps:get(exchanges, All), + Bindings = maps:get(bindings, All), + assert_list(maps:get(queues, Topology), Queues), + assert_list(maps:get(exchanges, Topology), Exchanges), + assert_list(maps:get(bindings, Topology), Bindings). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor