فهرست منبع

fix(config_api): remove config APIs that already been provided by apps

Shawn 4 سال پیش
والد
کامیت
5f6bcd1ebb
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      apps/emqx_management/src/emqx_mgmt_api_configs.erl

+ 7 - 1
apps/emqx_management/src/emqx_mgmt_api_configs.erl

@@ -48,12 +48,15 @@
 
 -define(ERR_MSG(MSG), list_to_binary(io_lib:format("~p", [MSG]))).
 
+-define(CORE_CONFS, [node, log, alarm, zones, cluster, rpc, broker, sysmon,
+    emqx_dashboard, emqx_management]).
+
 api_spec() ->
     {config_apis() ++ [config_reset_api()], []}.
 
 config_apis() ->
     [config_api(ConfPath, Schema) || {ConfPath, Schema} <-
-     get_conf_schema(emqx_config:get([]), ?MAX_DEPTH)].
+     get_conf_schema(emqx_config:get([]), ?MAX_DEPTH), is_core_conf(ConfPath)].
 
 config_api(ConfPath, Schema) ->
     Path = path_join(ConfPath),
@@ -193,6 +196,9 @@ path_join([P], _Sp) -> str(P);
 path_join([P | Path], Sp) ->
     str(P) ++ Sp ++ path_join(Path, Sp).
 
+is_core_conf(Path) ->
+    lists:member(hd(Path), ?CORE_CONFS).
+
 str(S) when is_list(S) -> S;
 str(S) when is_binary(S) -> binary_to_list(S);
 str(S) when is_atom(S) -> atom_to_list(S).