feat(mgmt): ignore emqx_dashboard API and apps API
This commit is contained in:
parent
c0c5bcc698
commit
5434aa02ff
|
@ -60,7 +60,7 @@ start_listener({Proto, Port, Options}) ->
|
||||||
Minirest = #{
|
Minirest = #{
|
||||||
protocol => Proto,
|
protocol => Proto,
|
||||||
base_path => ?BASE_PATH,
|
base_path => ?BASE_PATH,
|
||||||
apps => apps(),
|
modules => minirest_api:find_api_modules(apps()),
|
||||||
authorization => Authorization,
|
authorization => Authorization,
|
||||||
security => [#{application => []}],
|
security => [#{application => []}],
|
||||||
swagger_global_spec => GlobalSpec,
|
swagger_global_spec => GlobalSpec,
|
||||||
|
|
|
@ -54,10 +54,11 @@ start_listener({Proto, Port, Options}) ->
|
||||||
type => apiKey,
|
type => apiKey,
|
||||||
name => "authorization",
|
name => "authorization",
|
||||||
in => header}}}},
|
in => header}}}},
|
||||||
|
Modules = minirest_api:find_api_modules(apps()) -- [emqx_mgmt_api_apps],
|
||||||
Minirest = #{
|
Minirest = #{
|
||||||
protocol => Proto,
|
protocol => Proto,
|
||||||
base_path => ?BASE_PATH,
|
base_path => ?BASE_PATH,
|
||||||
apps => apps(),
|
modules => Modules,
|
||||||
authorization => Authorization,
|
authorization => Authorization,
|
||||||
security => [#{application => []}],
|
security => [#{application => []}],
|
||||||
swagger_global_spec => GlobalSpec},
|
swagger_global_spec => GlobalSpec},
|
||||||
|
@ -65,15 +66,6 @@ start_listener({Proto, Port, Options}) ->
|
||||||
{ok, _} = minirest:start(listener_name(Proto), MinirestOptions),
|
{ok, _} = minirest:start(listener_name(Proto), MinirestOptions),
|
||||||
io:format("Start ~p listener on ~p successfully.~n", [listener_name(Proto), Port]).
|
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) ->
|
ranch_opts(Port, Options0) ->
|
||||||
Options = lists:foldl(
|
Options = lists:foldl(
|
||||||
fun
|
fun
|
||||||
|
@ -116,3 +108,12 @@ format({Addr, Port}) when is_list(Addr) ->
|
||||||
io_lib:format("~s:~w", [Addr, Port]);
|
io_lib:format("~s:~w", [Addr, Port]);
|
||||||
format({Addr, Port}) when is_tuple(Addr) ->
|
format({Addr, Port}) when is_tuple(Addr) ->
|
||||||
io_lib:format("~s:~w", [inet:ntoa(Addr), Port]).
|
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).
|
||||||
|
|
Loading…
Reference in New Issue