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, #{
|
clients_insta(get, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
clientid := ClientId0
|
clientid := ClientId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
case
|
case
|
||||||
emqx_gateway_http:lookup_client(
|
emqx_gateway_http:lookup_client(
|
||||||
|
@ -172,10 +171,9 @@ clients_insta(get, #{
|
||||||
clients_insta(delete, #{
|
clients_insta(delete, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
clientid := ClientId0
|
clientid := ClientId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
_ = emqx_gateway_http:kickout_client(GwName, ClientId),
|
_ = emqx_gateway_http:kickout_client(GwName, ClientId),
|
||||||
{204}
|
{204}
|
||||||
|
@ -185,10 +183,9 @@ clients_insta(delete, #{
|
||||||
subscriptions(get, #{
|
subscriptions(get, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
clientid := ClientId0
|
clientid := ClientId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
|
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
|
@ -203,11 +200,10 @@ subscriptions(get, #{
|
||||||
subscriptions(post, #{
|
subscriptions(post, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
clientid := ClientId0
|
clientid := ClientId
|
||||||
},
|
},
|
||||||
body := Body
|
body := Body
|
||||||
}) ->
|
}) ->
|
||||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
case {maps:get(<<"topic">>, Body, undefined), subopts(Body)} of
|
case {maps:get(<<"topic">>, Body, undefined), subopts(Body)} of
|
||||||
{undefined, _} ->
|
{undefined, _} ->
|
||||||
|
@ -231,12 +227,10 @@ subscriptions(post, #{
|
||||||
subscriptions(delete, #{
|
subscriptions(delete, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
clientid := ClientId0,
|
clientid := ClientId,
|
||||||
topic := Topic0
|
topic := Topic
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ClientId = emqx_mgmt_util:urldecode(ClientId0),
|
|
||||||
Topic = emqx_mgmt_util:urldecode(Topic0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
_ = emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic),
|
_ = emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic),
|
||||||
{204}
|
{204}
|
||||||
|
|
|
@ -110,14 +110,12 @@ listeners(post, #{bindings := #{name := Name0}, body := LConf}) ->
|
||||||
end
|
end
|
||||||
end).
|
end).
|
||||||
|
|
||||||
listeners_insta(delete, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
listeners_insta(delete, #{bindings := #{name := Name0, id := ListenerId}}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(_GwName, _) ->
|
with_gateway(Name0, fun(_GwName, _) ->
|
||||||
ok = emqx_gateway_http:remove_listener(ListenerId),
|
ok = emqx_gateway_http:remove_listener(ListenerId),
|
||||||
{204}
|
{204}
|
||||||
end);
|
end);
|
||||||
listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId}}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(_GwName, _) ->
|
with_gateway(Name0, fun(_GwName, _) ->
|
||||||
case emqx_gateway_conf:listener(ListenerId) of
|
case emqx_gateway_conf:listener(ListenerId) of
|
||||||
{ok, Listener} ->
|
{ok, Listener} ->
|
||||||
|
@ -130,9 +128,8 @@ listeners_insta(get, #{bindings := #{name := Name0, id := ListenerId0}}) ->
|
||||||
end);
|
end);
|
||||||
listeners_insta(put, #{
|
listeners_insta(put, #{
|
||||||
body := LConf,
|
body := LConf,
|
||||||
bindings := #{name := Name0, id := ListenerId0}
|
bindings := #{name := Name0, id := ListenerId}
|
||||||
}) ->
|
}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(_GwName, _) ->
|
with_gateway(Name0, fun(_GwName, _) ->
|
||||||
{ok, RespConf} = emqx_gateway_http:update_listener(ListenerId, LConf),
|
{ok, RespConf} = emqx_gateway_http:update_listener(ListenerId, LConf),
|
||||||
{200, RespConf}
|
{200, RespConf}
|
||||||
|
@ -141,10 +138,9 @@ listeners_insta(put, #{
|
||||||
listeners_insta_authn(get, #{
|
listeners_insta_authn(get, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
id := ListenerId0
|
id := ListenerId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
try emqx_gateway_http:authn(GwName, ListenerId) of
|
try emqx_gateway_http:authn(GwName, ListenerId) of
|
||||||
Authn -> {200, Authn}
|
Authn -> {200, Authn}
|
||||||
|
@ -157,10 +153,9 @@ listeners_insta_authn(post, #{
|
||||||
body := Conf,
|
body := Conf,
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
id := ListenerId0
|
id := ListenerId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
{ok, Authn} = emqx_gateway_http:add_authn(GwName, ListenerId, Conf),
|
{ok, Authn} = emqx_gateway_http:add_authn(GwName, ListenerId, Conf),
|
||||||
{201, Authn}
|
{201, Authn}
|
||||||
|
@ -169,10 +164,9 @@ listeners_insta_authn(put, #{
|
||||||
body := Conf,
|
body := Conf,
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
id := ListenerId0
|
id := ListenerId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
{ok, Authn} = emqx_gateway_http:update_authn(
|
{ok, Authn} = emqx_gateway_http:update_authn(
|
||||||
GwName, ListenerId, Conf
|
GwName, ListenerId, Conf
|
||||||
|
@ -182,10 +176,9 @@ listeners_insta_authn(put, #{
|
||||||
listeners_insta_authn(delete, #{
|
listeners_insta_authn(delete, #{
|
||||||
bindings := #{
|
bindings := #{
|
||||||
name := Name0,
|
name := Name0,
|
||||||
id := ListenerId0
|
id := ListenerId
|
||||||
}
|
}
|
||||||
}) ->
|
}) ->
|
||||||
ListenerId = emqx_mgmt_util:urldecode(ListenerId0),
|
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
ok = emqx_gateway_http:remove_authn(GwName, ListenerId),
|
ok = emqx_gateway_http:remove_authn(GwName, ListenerId),
|
||||||
{204}
|
{204}
|
||||||
|
|
Loading…
Reference in New Issue