Merge pull request #7153 from DDDHuang/etm_urlencode

fix: remove bindings params url decode (url decode by minirest)
This commit is contained in:
DDDHuang 2022-02-28 13:38:09 +08:00 committed by GitHub
commit d8cf4421aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 9 deletions

View File

@ -231,18 +231,16 @@ fields(metrics) ->
topic(In) -> topic(In) ->
case In of case In of
body -> body ->
Desc = <<"Raw topic string">>, Desc = <<"Raw topic string">>;
Example = "testtopic/1";
path -> path ->
Desc = <<"Notice: Topic string in url path must be encoded">>, Desc = <<"Notice: Topic string in url path must be encoded">>
Example = "testtopic%2F1"
end, end,
{ topic { topic
, mk( binary(), , mk( binary(),
#{ desc => Desc #{ desc => Desc
, required => true , required => true
, in => In , in => In
, example => Example , example => <<"testtopic/1">>
}) })
}. }.
@ -290,11 +288,11 @@ topic_metrics(post, #{body := #{<<"topic">> := Topic}}) ->
reason2httpresp(Reason) reason2httpresp(Reason)
end. end.
operate_topic_metrics(get, #{bindings := #{topic := Topic0}}) -> operate_topic_metrics(get, #{bindings := #{topic := Topic}}) ->
get_cluster_response([emqx_http_lib:uri_decode(Topic0)]); get_cluster_response([Topic]);
operate_topic_metrics(delete, #{bindings := #{topic := Topic0}}) -> operate_topic_metrics(delete, #{bindings := #{topic := Topic}}) ->
case emqx_modules_conf:remove_topic_metrics(emqx_http_lib:uri_decode(Topic0)) of case emqx_modules_conf:remove_topic_metrics(Topic) of
ok -> {204}; ok -> {204};
{error, Reason} -> reason2httpresp(Reason) {error, Reason} -> reason2httpresp(Reason)
end. end.