feat(mgmt): ignore emqx_dashboard API and apps API

This commit is contained in:
Turtle 2021-07-26 18:36:59 +08:00 committed by turtleDeng
parent c0c5bcc698
commit 5434aa02ff
2 changed files with 12 additions and 11 deletions

View File

@ -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,

View File

@ -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).