chore(emqx_modules): add emqx_modules api path

This commit is contained in:
zhanghongtong 2021-03-02 18:02:18 +08:00 committed by JianBo He
parent 8e5cfaf0cc
commit db92f79713
1 changed files with 2 additions and 5 deletions

View File

@ -85,7 +85,7 @@ listener_name(Proto) ->
http_handlers() -> http_handlers() ->
Plugins = lists:map(fun(Plugin) -> Plugin#plugin.name end, emqx_plugins:list()), Plugins = lists:map(fun(Plugin) -> Plugin#plugin.name end, emqx_plugins:list()),
[{"/api/v4", minirest:handler(#{apps => Plugins -- ?EXCEPT_PLUGIN, [{"/api/v4", minirest:handler(#{apps => Plugins ++ [emqx_modules] -- ?EXCEPT_PLUGIN,
except => ?EXCEPT, except => ?EXCEPT,
filter => fun filter/1}), filter => fun filter/1}),
[{authorization, fun authorize_appid/1}]}]. [{authorization, fun authorize_appid/1}]}].
@ -119,15 +119,12 @@ authorize_appid(Req) ->
_ -> false _ -> false
end. end.
-ifdef(EMQX_ENTERPRISE). filter(#{app := emqx_modules}) -> true;
filter(_) -> true.
-else.
filter(#{app := App}) -> filter(#{app := App}) ->
case emqx_plugins:find_plugin(App) of case emqx_plugins:find_plugin(App) of
false -> false; false -> false;
Plugin -> Plugin#plugin.active Plugin -> Plugin#plugin.active
end. end.
-endif.
format(Port) when is_integer(Port) -> format(Port) when is_integer(Port) ->
io_lib:format("0.0.0.0:~w", [Port]); io_lib:format("0.0.0.0:~w", [Port]);