Merge pull request #8470 from DDDHuang/tpm_check
fix(api): topic metrics check exist before create
This commit is contained in:
commit
88ca8ff503
|
@ -1,7 +1,7 @@
|
|||
%% -*- mode: erlang -*-
|
||||
{application, emqx_modules, [
|
||||
{description, "EMQX Modules"},
|
||||
{vsn, "5.0.1"},
|
||||
{vsn, "5.0.2"},
|
||||
{modules, []},
|
||||
{applications, [kernel, stdlib, emqx]},
|
||||
{mod, {emqx_modules_app, []}},
|
||||
|
|
|
@ -296,11 +296,16 @@ topic_metrics(put, #{body := #{<<"action">> := <<"reset">>}}) ->
|
|||
topic_metrics(post, #{body := #{<<"topic">> := <<>>}}) ->
|
||||
{400, 'BAD_REQUEST', <<"Topic can not be empty">>};
|
||||
topic_metrics(post, #{body := #{<<"topic">> := Topic}}) ->
|
||||
case lists:member(Topic, emqx_modules_conf:topic_metrics()) of
|
||||
false ->
|
||||
case emqx_modules_conf:add_topic_metrics(Topic) of
|
||||
{ok, Topic} ->
|
||||
get_cluster_response([Topic]);
|
||||
{error, Reason} ->
|
||||
reason2httpresp(Reason)
|
||||
end;
|
||||
true ->
|
||||
reason2httpresp(already_existed)
|
||||
end.
|
||||
|
||||
operate_topic_metrics(get, #{bindings := #{topic := Topic}}) ->
|
||||
|
|
Loading…
Reference in New Issue