From 0e3310f1cfe628895eeb93e7fa410252d313bf0f Mon Sep 17 00:00:00 2001 From: DDDHuang <44492639+DDDHuang@users.noreply.github.com> Date: Mon, 28 Feb 2022 11:13:23 +0800 Subject: [PATCH 1/2] fix: remove bindings params url decode (url decode by minirest) --- apps/emqx_modules/src/emqx_topic_metrics_api.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/emqx_modules/src/emqx_topic_metrics_api.erl b/apps/emqx_modules/src/emqx_topic_metrics_api.erl index ddd7ffe88..c7de65b66 100644 --- a/apps/emqx_modules/src/emqx_topic_metrics_api.erl +++ b/apps/emqx_modules/src/emqx_topic_metrics_api.erl @@ -290,11 +290,11 @@ topic_metrics(post, #{body := #{<<"topic">> := Topic}}) -> reason2httpresp(Reason) end. -operate_topic_metrics(get, #{bindings := #{topic := Topic0}}) -> - get_cluster_response([emqx_http_lib:uri_decode(Topic0)]); +operate_topic_metrics(get, #{bindings := #{topic := Topic}}) -> + get_cluster_response([Topic]); -operate_topic_metrics(delete, #{bindings := #{topic := Topic0}}) -> - case emqx_modules_conf:remove_topic_metrics(emqx_http_lib:uri_decode(Topic0)) of +operate_topic_metrics(delete, #{bindings := #{topic := Topic}}) -> + case emqx_modules_conf:remove_topic_metrics(Topic) of ok -> {204}; {error, Reason} -> reason2httpresp(Reason) end. From d82a5544da07dd1b021d9456c74d5fc86bd31cc6 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Mon, 28 Feb 2022 11:33:26 +0800 Subject: [PATCH 2/2] fix: topic_metrics example --- apps/emqx_modules/src/emqx_topic_metrics_api.erl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/emqx_modules/src/emqx_topic_metrics_api.erl b/apps/emqx_modules/src/emqx_topic_metrics_api.erl index c7de65b66..9e8223d04 100644 --- a/apps/emqx_modules/src/emqx_topic_metrics_api.erl +++ b/apps/emqx_modules/src/emqx_topic_metrics_api.erl @@ -231,18 +231,16 @@ fields(metrics) -> topic(In) -> case In of body -> - Desc = <<"Raw topic string">>, - Example = "testtopic/1"; + Desc = <<"Raw topic string">>; path -> - Desc = <<"Notice: Topic string in url path must be encoded">>, - Example = "testtopic%2F1" + Desc = <<"Notice: Topic string in url path must be encoded">> end, { topic , mk( binary(), #{ desc => Desc , required => true , in => In - , example => Example + , example => <<"testtopic/1">> }) }.