88-import (rabbit_amqp_session ,
99 [check_resource_access /4 ,
1010 check_read_permitted_on_topic /4 ]).
11+ -import (rabbit_misc ,
12+ [queue_resource /2 ,
13+ exchange_resource /2 ]).
1114
1215-type permission_caches () :: {rabbit_amqp_session :permission_cache (),
1316 rabbit_amqp_session :topic_permission_cache ()}.
@@ -78,7 +81,7 @@ handle_http_req(<<"GET">>,
7881 _ConnPid ,
7982 PermCaches ) ->
8083 QNameBin = uri_string :unquote (QNameBinQuoted ),
81- QName = rabbit_misc : r (Vhost , queue , QNameBin ),
84+ QName = queue_resource (Vhost , QNameBin ),
8285 case rabbit_amqqueue :with (
8386 QName ,
8487 fun (Q ) ->
@@ -119,7 +122,7 @@ handle_http_req(HttpMethod = <<"PUT">>,
119122 _ -> ok
120123 end ,
121124 ok = prohibit_cr_lf (QNameBin ),
122- QName = rabbit_misc : r (Vhost , queue , QNameBin ),
125+ QName = queue_resource (Vhost , QNameBin ),
123126 ok = prohibit_reserved_amq (QName ),
124127 PermCache1 = check_resource_access (QName , configure , User , PermCache0 ),
125128 rabbit_core_metrics :queue_declared (QName ),
@@ -193,7 +196,7 @@ handle_http_req(<<"PUT">>,
193196 catch exit :# amqp_error {explanation = Explanation } ->
194197 throw (<<" 400" >>, Explanation , [])
195198 end ,
196- XName = rabbit_misc : r (Vhost , exchange , XNameBin ),
199+ XName = exchange_resource (Vhost , XNameBin ),
197200 ok = prohibit_default_exchange (XName ),
198201 PermCache = check_resource_access (XName , configure , User , PermCache0 ),
199202 X = case rabbit_exchange :lookup (XName ) of
@@ -224,7 +227,7 @@ handle_http_req(<<"DELETE">>,
224227 ConnPid ,
225228 {PermCache0 , TopicPermCache }) ->
226229 QNameBin = uri_string :unquote (QNameBinQuoted ),
227- QName = rabbit_misc : r (Vhost , queue , QNameBin ),
230+ QName = queue_resource (Vhost , QNameBin ),
228231 PermCache = check_resource_access (QName , read , User , PermCache0 ),
229232 try rabbit_amqqueue :with_exclusive_access_or_die (
230233 QName , ConnPid ,
@@ -252,7 +255,7 @@ handle_http_req(<<"DELETE">>,
252255 ConnPid ,
253256 {PermCache0 , TopicPermCache }) ->
254257 QNameBin = uri_string :unquote (QNameBinQuoted ),
255- QName = rabbit_misc : r (Vhost , queue , QNameBin ),
258+ QName = queue_resource (Vhost , QNameBin ),
256259 ok = prohibit_cr_lf (QNameBin ),
257260 PermCache = check_resource_access (QName , configure , User , PermCache0 ),
258261 try rabbit_amqqueue :delete_with (QName , ConnPid , false , false , Username , true ) of
@@ -272,7 +275,7 @@ handle_http_req(<<"DELETE">>,
272275 _ConnPid ,
273276 {PermCache0 , TopicPermCache }) ->
274277 XNameBin = uri_string :unquote (XNameBinQuoted ),
275- XName = rabbit_misc : r (Vhost , exchange , XNameBin ),
278+ XName = exchange_resource (Vhost , XNameBin ),
276279 ok = prohibit_cr_lf (XNameBin ),
277280 ok = prohibit_default_exchange (XName ),
278281 ok = prohibit_reserved_amq (XName ),
@@ -297,7 +300,7 @@ handle_http_req(<<"POST">>,
297300 #{destination_exchange := Bin } ->
298301 {exchange , Bin }
299302 end ,
300- SrcXName = rabbit_misc : r (Vhost , exchange , SrcXNameBin ),
303+ SrcXName = exchange_resource (Vhost , SrcXNameBin ),
301304 DstName = rabbit_misc :r (Vhost , DstKind , DstNameBin ),
302305 PermCaches = binding_checks (SrcXName , DstName , BindingKey , User , PermCaches0 ),
303306 Binding = # binding {source = SrcXName ,
@@ -320,7 +323,7 @@ handle_http_req(<<"DELETE">>,
320323 DstNameBin ,
321324 BindingKey ,
322325 ArgsHash } = decode_binding_path_segment (BindingSegment ),
323- SrcXName = rabbit_misc : r (Vhost , exchange , SrcXNameBin ),
326+ SrcXName = exchange_resource (Vhost , SrcXNameBin ),
324327 DstName = rabbit_misc :r (Vhost , DstKind , DstNameBin ),
325328 PermCaches = binding_checks (SrcXName , DstName , BindingKey , User , PermCaches0 ),
326329 Bindings = rabbit_binding :list_for_source_and_destination (SrcXName , DstName ),
@@ -352,7 +355,7 @@ handle_http_req(<<"GET">>,
352355 " missing 'dste' or 'dstq' in query: ~tp " ,
353356 QueryMap )
354357 end ,
355- SrcXName = rabbit_misc : r (Vhost , exchange , SrcXNameBin ),
358+ SrcXName = exchange_resource (Vhost , SrcXNameBin ),
356359 DstName = rabbit_misc :r (Vhost , DstKind , DstNameBin ),
357360 Bindings0 = rabbit_binding :list_for_source_and_destination (SrcXName , DstName ),
358361 Bindings = [B || B = # binding {key = K } <- Bindings0 , K =:= Key ],
0 commit comments