fix(mgmt): remove the `/api/v5` prefix of status API

This commit is contained in:
firest 2022-08-08 17:34:18 +08:00
parent e9d7cde0b4
commit 01ba45cc37
2 changed files with 10 additions and 39 deletions

View File

@ -73,6 +73,7 @@ start_listeners(Listeners) ->
Dispatch = [ Dispatch = [
{"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}, {"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}},
{"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}}, {"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}},
{emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []},
{?BASE_PATH ++ "/[...]", emqx_dashboard_bad_api, []}, {?BASE_PATH ++ "/[...]", emqx_dashboard_bad_api, []},
{'_', cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}} {'_', cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}
], ],

View File

@ -14,55 +14,25 @@
%% limitations under the License. %% limitations under the License.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-module(emqx_mgmt_api_status). -module(emqx_mgmt_api_status).
%% API
-behaviour(minirest_api).
-export([ -export([
api_spec/0, init/2,
paths/0, path/0
schema/1
]). ]).
-export([running_status/2]). path() ->
"/status".
api_spec() -> init(Req0, State) ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). {Code, Headers, Body} = running_status(),
Req = cowboy_req:reply(Code, Headers, Body, Req0),
paths() -> {ok, Req, State}.
["/status"].
schema("/status") ->
#{
'operationId' => running_status,
get =>
#{
description => <<"Node running status">>,
tags => [<<"Status">>],
security => [],
responses =>
#{
200 =>
#{
description => <<"Node is running">>,
content =>
#{
'text/plain' =>
#{
schema => #{type => string},
example =>
<<"Node emqx@127.0.0.1 is started\nemqx is running">>
}
}
}
}
}
}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% API Handler funcs %% API Handler funcs
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
running_status(get, _Params) -> running_status() ->
BrokerStatus = BrokerStatus =
case emqx:is_running() of case emqx:is_running() of
true -> true ->