fix(gateway): avoid uri_decode twice
The url path has beed decoded in
0ebceb432f/src/cowboy_router.erl (L324-L330)
.
So, we don't need uri_decode in minirest callback again.
This commit is contained in:
parent
d77d5e33bc
commit
c5398ab651
|
@ -145,10 +145,9 @@ clients(get, #{
|
|||
clients_insta(get, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
clientid := ClientId0
|
||||
clientid := ClientId
|
||||
}
|
||||
}) ->
|
||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
case
|
||||
emqx_gateway_http:lookup_client(
|
||||
|
@ -172,10 +171,9 @@ clients_insta(get, #{
|
|||
clients_insta(delete, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
clientid := ClientId0
|
||||
clientid := ClientId
|
||||
}
|
||||
}) ->
|
||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
_ = emqx_gateway_http:kickout_client(GwName, ClientId),
|
||||
{204}
|
||||
|
@ -185,10 +183,9 @@ clients_insta(delete, #{
|
|||
subscriptions(get, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
clientid := ClientId0
|
||||
clientid := ClientId
|
||||
}
|
||||
}) ->
|
||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
|
||||
{error, not_found} ->
|
||||
|
@ -203,11 +200,10 @@ subscriptions(get, #{
|
|||
subscriptions(post, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
clientid := ClientId0
|
||||
clientid := ClientId
|
||||
},
|
||||
body := Body
|
||||
}) ->
|
||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
case {maps:get(<<"topic">>, Body, undefined), subopts(Body)} of
|
||||
{undefined, _} ->
|
||||
|
@ -231,12 +227,10 @@ subscriptions(post, #{
|
|||
subscriptions(delete, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
clientid := ClientId0,
|
||||
topic := Topic0
|
||||
clientid := ClientId,
|
||||
topic := Topic
|
||||
}
|
||||
}) ->
|
||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
||||
Topic = emqx_mgmt_util:urldecode(Topic0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
_ = emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic),
|
||||
{204}
|
||||
|
|
|
@ -110,14 +110,12 @@ listeners(post, #{bindings := #{name := Name0}, body := LConf}) ->
|
|||
end
|
||||
end).
|
||||
|
||||
listeners_insta(delete, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
listeners_insta(delete, #{bindings := #{name := Name0, id := ListenerId}}) ->
|
||||
with_gateway(Name0, fun(_GwName, _) ->
|
||||
ok = emqx_gateway_http:remove_listener(ListenerId),
|
||||
{204}
|
||||
end);
|
||||
listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId}}) ->
|
||||
with_gateway(Name0, fun(_GwName, _) ->
|
||||
case emqx_gateway_conf:listener(ListenerId) of
|
||||
{ok, Listener} ->
|
||||
|
@ -130,9 +128,8 @@ listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
|||
end);
|
||||
listeners_insta(put, #{
|
||||
body := LConf,
|
||||
bindings := #{name := Name0, id := ListenerId0}
|
||||
bindings := #{name := Name0, id := ListenerId}
|
||||
}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
with_gateway(Name0, fun(_GwName, _) ->
|
||||
{ok, RespConf} = emqx_gateway_http:update_listener(ListenerId, LConf),
|
||||
{200, RespConf}
|
||||
|
@ -141,10 +138,9 @@ listeners_insta(put, #{
|
|||
listeners_insta_authn(get, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
id := ListenerId0
|
||||
id := ListenerId
|
||||
}
|
||||
}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
try emqx_gateway_http:authn(GwName, ListenerId) of
|
||||
Authn -> {200, Authn}
|
||||
|
@ -157,10 +153,9 @@ listeners_insta_authn(post, #{
|
|||
body := Conf,
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
id := ListenerId0
|
||||
id := ListenerId
|
||||
}
|
||||
}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
{ok, Authn} = emqx_gateway_http:add_authn(GwName, ListenerId, Conf),
|
||||
{201, Authn}
|
||||
|
@ -169,10 +164,9 @@ listeners_insta_authn(put, #{
|
|||
body := Conf,
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
id := ListenerId0
|
||||
id := ListenerId
|
||||
}
|
||||
}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
{ok, Authn} = emqx_gateway_http:update_authn(
|
||||
GwName, ListenerId, Conf
|
||||
|
@ -182,10 +176,9 @@ listeners_insta_authn(put, #{
|
|||
listeners_insta_authn(delete, #{
|
||||
bindings := #{
|
||||
name := Name0,
|
||||
id := ListenerId0
|
||||
id := ListenerId
|
||||
}
|
||||
}) ->
|
||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
ok = emqx_gateway_http:remove_authn(GwName, ListenerId),
|
||||
{204}
|
||||
|
|
Loading…
Reference in New Issue