Просмотр исходного кода

feat(mgmt): ignore emqx_dashboard API and apps API

Turtle 4 лет назад
Родитель
Сommit
5434aa02ff

+ 1 - 1
apps/emqx_dashboard/src/emqx_dashboard.erl

@@ -60,7 +60,7 @@ start_listener({Proto, Port, Options}) ->
     Minirest = #{
         protocol => Proto,
         base_path => ?BASE_PATH,
-        apps => apps(),
+        modules => minirest_api:find_api_modules(apps()),
         authorization => Authorization,
         security => [#{application => []}],
         swagger_global_spec => GlobalSpec,

+ 11 - 10
apps/emqx_management/src/emqx_mgmt_http.erl

@@ -54,10 +54,11 @@ start_listener({Proto, Port, Options}) ->
                     type => apiKey,
                     name => "authorization",
                     in => header}}}},
+    Modules = minirest_api:find_api_modules(apps()) -- [emqx_mgmt_api_apps],
     Minirest = #{
         protocol => Proto,
         base_path => ?BASE_PATH,
-        apps => apps(),
+        modules => Modules,
         authorization => Authorization,
         security => [#{application => []}],
         swagger_global_spec => GlobalSpec},
@@ -65,15 +66,6 @@ start_listener({Proto, Port, Options}) ->
     {ok, _} = minirest:start(listener_name(Proto), MinirestOptions),
     io:format("Start ~p listener on ~p successfully.~n", [listener_name(Proto), Port]).
 
-apps() ->
-    Apps = [App || {App, _, _} <- application:loaded_applications(),
-        case re:run(atom_to_list(App), "^emqx") of
-            {match,[{0,4}]} -> true;
-            _ -> false
-        end],
-    Plugins = lists:map(fun(Plugin) -> Plugin#plugin.name end, emqx_plugins:list()),
-    Apps ++ Plugins.
-
 ranch_opts(Port, Options0) ->
     Options = lists:foldl(
                   fun
@@ -116,3 +108,12 @@ format({Addr, Port}) when is_list(Addr) ->
     io_lib:format("~s:~w", [Addr, Port]);
 format({Addr, Port}) when is_tuple(Addr) ->
     io_lib:format("~s:~w", [inet:ntoa(Addr), Port]).
+
+apps() ->
+    Apps = [App || {App, _, _} <- application:loaded_applications(), App =/= emqx_dashboard],
+    lists:filter(fun(App) ->
+        case re:run(atom_to_list(App), "^emqx") of
+            {match,[{0,4}]} -> true;
+            _ -> false
+        end
+    end, Apps).