style(api): minirest imports removed
This commit is contained in:
parent
20086bcff1
commit
ea384ec6b5
|
@ -20,10 +20,6 @@
|
||||||
|
|
||||||
-import(proplists, [get_value/2]).
|
-import(proplists, [get_value/2]).
|
||||||
|
|
||||||
-import(minirest, [ return/0
|
|
||||||
, return/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
-rest_api(#{name => add_app,
|
-rest_api(#{name => add_app,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
path => "/apps/",
|
path => "/apps/",
|
||||||
|
@ -69,30 +65,30 @@ add_app(_Bindings, Params) ->
|
||||||
Status = get_value(<<"status">>, Params),
|
Status = get_value(<<"status">>, Params),
|
||||||
Expired = get_value(<<"expired">>, Params),
|
Expired = get_value(<<"expired">>, Params),
|
||||||
case emqx_mgmt_auth:add_app(AppId, Name, Secret, Desc, Status, Expired) of
|
case emqx_mgmt_auth:add_app(AppId, Name, Secret, Desc, Status, Expired) of
|
||||||
{ok, AppSecret} -> return({ok, #{secret => AppSecret}});
|
{ok, AppSecret} -> minirest:return({ok, #{secret => AppSecret}});
|
||||||
{error, Reason} -> return({error, Reason})
|
{error, Reason} -> minirest:return({error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
del_app(#{appid := AppId}, _Params) ->
|
del_app(#{appid := AppId}, _Params) ->
|
||||||
case emqx_mgmt_auth:del_app(AppId) of
|
case emqx_mgmt_auth:del_app(AppId) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, Reason} -> return({error, Reason})
|
{error, Reason} -> minirest:return({error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
list_apps(_Bindings, _Params) ->
|
list_apps(_Bindings, _Params) ->
|
||||||
return({ok, [format(Apps)|| Apps <- emqx_mgmt_auth:list_apps()]}).
|
minirest:return({ok, [format(Apps)|| Apps <- emqx_mgmt_auth:list_apps()]}).
|
||||||
|
|
||||||
lookup_app(#{appid := AppId}, _Params) ->
|
lookup_app(#{appid := AppId}, _Params) ->
|
||||||
case emqx_mgmt_auth:lookup_app(AppId) of
|
case emqx_mgmt_auth:lookup_app(AppId) of
|
||||||
{AppId, AppSecret, Name, Desc, Status, Expired} ->
|
{AppId, AppSecret, Name, Desc, Status, Expired} ->
|
||||||
return({ok, #{app_id => AppId,
|
minirest:return({ok, #{app_id => AppId,
|
||||||
secret => AppSecret,
|
secret => AppSecret,
|
||||||
name => Name,
|
name => Name,
|
||||||
desc => Desc,
|
desc => Desc,
|
||||||
status => Status,
|
status => Status,
|
||||||
expired => Expired}});
|
expired => Expired}});
|
||||||
undefined ->
|
undefined ->
|
||||||
return({ok, #{}})
|
minirest:return({ok, #{}})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
update_app(#{appid := AppId}, Params) ->
|
update_app(#{appid := AppId}, Params) ->
|
||||||
|
@ -101,8 +97,8 @@ update_app(#{appid := AppId}, Params) ->
|
||||||
Status = get_value(<<"status">>, Params),
|
Status = get_value(<<"status">>, Params),
|
||||||
Expired = get_value(<<"expired">>, Params),
|
Expired = get_value(<<"expired">>, Params),
|
||||||
case emqx_mgmt_auth:update_app(AppId, Name, Desc, Status, Expired) of
|
case emqx_mgmt_auth:update_app(AppId, Name, Desc, Status, Expired) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, Reason} -> return({error, Reason})
|
{error, Reason} -> minirest:return({error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format({AppId, _AppSecret, Name, Desc, Status, Expired}) ->
|
format({AppId, _AppSecret, Name, Desc, Status, Expired}) ->
|
||||||
|
|
|
@ -22,10 +22,6 @@
|
||||||
|
|
||||||
-import(proplists, [get_value/2]).
|
-import(proplists, [get_value/2]).
|
||||||
|
|
||||||
-import(minirest, [ return/0
|
|
||||||
, return/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_banned,
|
-rest_api(#{name => list_banned,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/banned/",
|
path => "/banned/",
|
||||||
|
@ -50,7 +46,7 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
list(_Bindings, Params) ->
|
list(_Bindings, Params) ->
|
||||||
return({ok, emqx_mgmt_api:paginate(emqx_banned, Params, fun format/1)}).
|
minirest:return({ok, emqx_mgmt_api:paginate(emqx_banned, Params, fun format/1)}).
|
||||||
|
|
||||||
create(_Bindings, Params) ->
|
create(_Bindings, Params) ->
|
||||||
case pipeline([fun ensure_required/1,
|
case pipeline([fun ensure_required/1,
|
||||||
|
@ -58,9 +54,9 @@ create(_Bindings, Params) ->
|
||||||
{ok, NParams} ->
|
{ok, NParams} ->
|
||||||
{ok, Banned} = pack_banned(NParams),
|
{ok, Banned} = pack_banned(NParams),
|
||||||
ok = emqx_mgmt:create_banned(Banned),
|
ok = emqx_mgmt:create_banned(Banned),
|
||||||
return({ok, maps:from_list(Params)});
|
minirest:return({ok, maps:from_list(Params)});
|
||||||
{error, Code, Message} ->
|
{error, Code, Message} ->
|
||||||
return({error, Code, Message})
|
minirest:return({error, Code, Message})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
delete(#{as := As, who := Who}, _) ->
|
delete(#{as := As, who := Who}, _) ->
|
||||||
|
@ -70,9 +66,9 @@ delete(#{as := As, who := Who}, _) ->
|
||||||
fun validate_params/1], Params) of
|
fun validate_params/1], Params) of
|
||||||
{ok, NParams} ->
|
{ok, NParams} ->
|
||||||
do_delete(get_value(<<"as">>, NParams), get_value(<<"who">>, NParams)),
|
do_delete(get_value(<<"as">>, NParams), get_value(<<"who">>, NParams)),
|
||||||
return();
|
minirest:return();
|
||||||
{error, Code, Message} ->
|
{error, Code, Message} ->
|
||||||
return({error, Code, Message})
|
minirest:return({error, Code, Message})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
pipeline([], Params) ->
|
pipeline([], Params) ->
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
-include("emqx_mgmt.hrl").
|
-include("emqx_mgmt.hrl").
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_brokers,
|
-rest_api(#{name => list_brokers,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/brokers/",
|
path => "/brokers/",
|
||||||
|
@ -37,13 +35,13 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
list(_Bindings, _Params) ->
|
list(_Bindings, _Params) ->
|
||||||
return({ok, [Info || {_Node, Info} <- emqx_mgmt:list_brokers()]}).
|
minirest:return({ok, [Info || {_Node, Info} <- emqx_mgmt:list_brokers()]}).
|
||||||
|
|
||||||
get(#{node := Node}, _Params) ->
|
get(#{node := Node}, _Params) ->
|
||||||
case emqx_mgmt:lookup_broker(Node) of
|
case emqx_mgmt:lookup_broker(Node) of
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return({error, ?ERROR2, Reason});
|
minirest:return({error, ?ERROR2, Reason});
|
||||||
Info ->
|
Info ->
|
||||||
return({ok, Info})
|
minirest:return({ok, Info})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,6 @@
|
||||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
|
|
||||||
-import(minirest, [ return/0
|
|
||||||
, return/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
-import(proplists, [get_value/2]).
|
-import(proplists, [get_value/2]).
|
||||||
|
|
||||||
-define(CLIENT_QS_SCHEMA, {emqx_channel_info,
|
-define(CLIENT_QS_SCHEMA, {emqx_channel_info,
|
||||||
|
@ -146,87 +142,87 @@
|
||||||
-define(format_fun, {?MODULE, format_channel_info}).
|
-define(format_fun, {?MODULE, format_channel_info}).
|
||||||
|
|
||||||
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
||||||
return({ok, emqx_mgmt_api:cluster_query(Params, ?CLIENT_QS_SCHEMA, ?query_fun)});
|
minirest:return({ok, emqx_mgmt_api:cluster_query(Params, ?CLIENT_QS_SCHEMA, ?query_fun)});
|
||||||
|
|
||||||
list(#{node := Node}, Params) when Node =:= node() ->
|
list(#{node := Node}, Params) when Node =:= node() ->
|
||||||
return({ok, emqx_mgmt_api:node_query(Node, Params, ?CLIENT_QS_SCHEMA, ?query_fun)});
|
minirest:return({ok, emqx_mgmt_api:node_query(Node, Params, ?CLIENT_QS_SCHEMA, ?query_fun)});
|
||||||
|
|
||||||
list(Bindings = #{node := Node}, Params) ->
|
list(Bindings = #{node := Node}, Params) ->
|
||||||
case rpc:call(Node, ?MODULE, list, [Bindings, Params]) of
|
case rpc:call(Node, ?MODULE, list, [Bindings, Params]) of
|
||||||
{badrpc, Reason} -> return({error, ?ERROR1, Reason});
|
{badrpc, Reason} -> minirest:return({error, ?ERROR1, Reason});
|
||||||
Res -> Res
|
Res -> Res
|
||||||
end.
|
end.
|
||||||
|
|
||||||
lookup(#{node := Node, clientid := ClientId}, _Params) ->
|
lookup(#{node := Node, clientid := ClientId}, _Params) ->
|
||||||
return({ok, emqx_mgmt:lookup_client(Node, {clientid, emqx_mgmt_util:urldecode(ClientId)}, ?format_fun)});
|
minirest:return({ok, emqx_mgmt:lookup_client(Node, {clientid, emqx_mgmt_util:urldecode(ClientId)}, ?format_fun)});
|
||||||
|
|
||||||
lookup(#{clientid := ClientId}, _Params) ->
|
lookup(#{clientid := ClientId}, _Params) ->
|
||||||
return({ok, emqx_mgmt:lookup_client({clientid, emqx_mgmt_util:urldecode(ClientId)}, ?format_fun)});
|
minirest:return({ok, emqx_mgmt:lookup_client({clientid, emqx_mgmt_util:urldecode(ClientId)}, ?format_fun)});
|
||||||
|
|
||||||
lookup(#{node := Node, username := Username}, _Params) ->
|
lookup(#{node := Node, username := Username}, _Params) ->
|
||||||
return({ok, emqx_mgmt:lookup_client(Node, {username, emqx_mgmt_util:urldecode(Username)}, ?format_fun)});
|
minirest:return({ok, emqx_mgmt:lookup_client(Node, {username, emqx_mgmt_util:urldecode(Username)}, ?format_fun)});
|
||||||
|
|
||||||
lookup(#{username := Username}, _Params) ->
|
lookup(#{username := Username}, _Params) ->
|
||||||
return({ok, emqx_mgmt:lookup_client({username, emqx_mgmt_util:urldecode(Username)}, ?format_fun)}).
|
minirest:return({ok, emqx_mgmt:lookup_client({username, emqx_mgmt_util:urldecode(Username)}, ?format_fun)}).
|
||||||
|
|
||||||
kickout(#{clientid := ClientId}, _Params) ->
|
kickout(#{clientid := ClientId}, _Params) ->
|
||||||
case emqx_mgmt:kickout_client(emqx_mgmt_util:urldecode(ClientId)) of
|
case emqx_mgmt:kickout_client(emqx_mgmt_util:urldecode(ClientId)) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clean_acl_cache(#{clientid := ClientId}, _Params) ->
|
clean_acl_cache(#{clientid := ClientId}, _Params) ->
|
||||||
case emqx_mgmt:clean_acl_cache(emqx_mgmt_util:urldecode(ClientId)) of
|
case emqx_mgmt:clean_acl_cache(emqx_mgmt_util:urldecode(ClientId)) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
list_acl_cache(#{clientid := ClientId}, _Params) ->
|
list_acl_cache(#{clientid := ClientId}, _Params) ->
|
||||||
case emqx_mgmt:list_acl_cache(emqx_mgmt_util:urldecode(ClientId)) of
|
case emqx_mgmt:list_acl_cache(emqx_mgmt_util:urldecode(ClientId)) of
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason});
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason});
|
||||||
Caches -> return({ok, [format_acl_cache(Cache) || Cache <- Caches]})
|
Caches -> minirest:return({ok, [format_acl_cache(Cache) || Cache <- Caches]})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_ratelimit_policy(#{clientid := ClientId}, Params) ->
|
set_ratelimit_policy(#{clientid := ClientId}, Params) ->
|
||||||
P = [{conn_bytes_in, get_value(<<"conn_bytes_in">>, Params)},
|
P = [{conn_bytes_in, get_value(<<"conn_bytes_in">>, Params)},
|
||||||
{conn_messages_in, get_value(<<"conn_messages_in">>, Params)}],
|
{conn_messages_in, get_value(<<"conn_messages_in">>, Params)}],
|
||||||
case [{K, parse_ratelimit_str(V)} || {K, V} <- P, V =/= undefined] of
|
case [{K, parse_ratelimit_str(V)} || {K, V} <- P, V =/= undefined] of
|
||||||
[] -> return();
|
[] -> minirest:return();
|
||||||
Policy ->
|
Policy ->
|
||||||
case emqx_mgmt:set_ratelimit_policy(emqx_mgmt_util:urldecode(ClientId), Policy) of
|
case emqx_mgmt:set_ratelimit_policy(emqx_mgmt_util:urldecode(ClientId), Policy) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clean_ratelimit(#{clientid := ClientId}, _Params) ->
|
clean_ratelimit(#{clientid := ClientId}, _Params) ->
|
||||||
case emqx_mgmt:set_ratelimit_policy(emqx_mgmt_util:urldecode(ClientId), []) of
|
case emqx_mgmt:set_ratelimit_policy(emqx_mgmt_util:urldecode(ClientId), []) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_quota_policy(#{clientid := ClientId}, Params) ->
|
set_quota_policy(#{clientid := ClientId}, Params) ->
|
||||||
P = [{conn_messages_routing, get_value(<<"conn_messages_routing">>, Params)}],
|
P = [{conn_messages_routing, get_value(<<"conn_messages_routing">>, Params)}],
|
||||||
case [{K, parse_ratelimit_str(V)} || {K, V} <- P, V =/= undefined] of
|
case [{K, parse_ratelimit_str(V)} || {K, V} <- P, V =/= undefined] of
|
||||||
[] -> return();
|
[] -> minirest:return();
|
||||||
Policy ->
|
Policy ->
|
||||||
case emqx_mgmt:set_quota_policy(emqx_mgmt_util:urldecode(ClientId), Policy) of
|
case emqx_mgmt:set_quota_policy(emqx_mgmt_util:urldecode(ClientId), Policy) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clean_quota(#{clientid := ClientId}, _Params) ->
|
clean_quota(#{clientid := ClientId}, _Params) ->
|
||||||
case emqx_mgmt:set_quota_policy(emqx_mgmt_util:urldecode(ClientId), []) of
|
case emqx_mgmt:set_quota_policy(emqx_mgmt_util:urldecode(ClientId), []) of
|
||||||
ok -> return();
|
ok -> minirest:return();
|
||||||
{error, not_found} -> return({error, ?ERROR12, not_found});
|
{error, not_found} -> minirest:return({error, ?ERROR12, not_found});
|
||||||
{error, Reason} -> return({error, ?ERROR1, Reason})
|
{error, Reason} -> minirest:return({error, ?ERROR1, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
|
|
|
@ -22,10 +22,6 @@
|
||||||
|
|
||||||
-include("emqx_mgmt.hrl").
|
-include("emqx_mgmt.hrl").
|
||||||
|
|
||||||
-import(minirest, [ return/0
|
|
||||||
, return/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
-rest_api(#{name => export,
|
-rest_api(#{name => export,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
path => "/data/export",
|
path => "/data/export",
|
||||||
|
@ -77,14 +73,14 @@
|
||||||
export(_Bindings, _Params) ->
|
export(_Bindings, _Params) ->
|
||||||
case emqx_mgmt_data_backup:export() of
|
case emqx_mgmt_data_backup:export() of
|
||||||
{ok, File = #{filename := Filename}} ->
|
{ok, File = #{filename := Filename}} ->
|
||||||
return({ok, File#{filename => filename:basename(Filename)}});
|
minirest:return({ok, File#{filename => filename:basename(Filename)}});
|
||||||
Return -> return(Return)
|
Return -> minirest:return(Return)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
list_exported(_Bindings, _Params) ->
|
list_exported(_Bindings, _Params) ->
|
||||||
List = [ rpc:call(Node, ?MODULE, get_list_exported, []) || Node <- ekka_mnesia:running_nodes() ],
|
List = [ rpc:call(Node, ?MODULE, get_list_exported, []) || Node <- ekka_mnesia:running_nodes() ],
|
||||||
NList = lists:map(fun({_, FileInfo}) -> FileInfo end, lists:keysort(1, lists:append(List))),
|
NList = lists:map(fun({_, FileInfo}) -> FileInfo end, lists:keysort(1, lists:append(List))),
|
||||||
return({ok, NList}).
|
minirest:return({ok, NList}).
|
||||||
|
|
||||||
get_list_exported() ->
|
get_list_exported() ->
|
||||||
Dir = emqx:get_env(data_dir),
|
Dir = emqx:get_env(data_dir),
|
||||||
|
@ -114,7 +110,7 @@ get_list_exported() ->
|
||||||
import(_Bindings, Params) ->
|
import(_Bindings, Params) ->
|
||||||
case proplists:get_value(<<"filename">>, Params) of
|
case proplists:get_value(<<"filename">>, Params) of
|
||||||
undefined ->
|
undefined ->
|
||||||
return({error, missing_required_params});
|
minirest:return({error, missing_required_params});
|
||||||
Filename ->
|
Filename ->
|
||||||
Result = case proplists:get_value(<<"node">>, Params) of
|
Result = case proplists:get_value(<<"node">>, Params) of
|
||||||
undefined -> do_import(Filename);
|
undefined -> do_import(Filename);
|
||||||
|
@ -122,11 +118,11 @@ import(_Bindings, Params) ->
|
||||||
case lists:member(Node,
|
case lists:member(Node,
|
||||||
[ erlang:atom_to_binary(N, utf8) || N <- ekka_mnesia:running_nodes() ]
|
[ erlang:atom_to_binary(N, utf8) || N <- ekka_mnesia:running_nodes() ]
|
||||||
) of
|
) of
|
||||||
true -> return(rpc:call(erlang:binary_to_atom(Node, utf8), ?MODULE, do_import, [Filename]));
|
true -> minirest:return(rpc:call(erlang:binary_to_atom(Node, utf8), ?MODULE, do_import, [Filename]));
|
||||||
false -> return({error, no_existent_node})
|
false -> minirest:return({error, no_existent_node})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
return(Result)
|
minirest:return(Result)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_import(Filename) ->
|
do_import(Filename) ->
|
||||||
|
@ -140,7 +136,7 @@ download(#{filename := Filename}, _Params) ->
|
||||||
{ok, #{filename => list_to_binary(Filename),
|
{ok, #{filename => list_to_binary(Filename),
|
||||||
file => Bin}};
|
file => Bin}};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return({error, Reason})
|
minirest:return({error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
upload(Bindings, Params) ->
|
upload(Bindings, Params) ->
|
||||||
|
@ -151,9 +147,9 @@ do_upload(_Bindings, #{<<"filename">> := Filename,
|
||||||
FullFilename = filename:join([emqx:get_env(data_dir), Filename]),
|
FullFilename = filename:join([emqx:get_env(data_dir), Filename]),
|
||||||
case file:write_file(FullFilename, Bin) of
|
case file:write_file(FullFilename, Bin) of
|
||||||
ok ->
|
ok ->
|
||||||
return({ok, [{node, node()}]});
|
minirest:return({ok, [{node, node()}]});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return({error, Reason})
|
minirest:return({error, Reason})
|
||||||
end;
|
end;
|
||||||
do_upload(Bindings, Params = #{<<"file">> := _}) ->
|
do_upload(Bindings, Params = #{<<"file">> := _}) ->
|
||||||
Seconds = erlang:system_time(second),
|
Seconds = erlang:system_time(second),
|
||||||
|
@ -161,13 +157,13 @@ do_upload(Bindings, Params = #{<<"file">> := _}) ->
|
||||||
Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
|
Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
|
||||||
do_upload(Bindings, Params#{<<"filename">> => Filename});
|
do_upload(Bindings, Params#{<<"filename">> => Filename});
|
||||||
do_upload(_Bindings, _Params) ->
|
do_upload(_Bindings, _Params) ->
|
||||||
return({error, missing_required_params}).
|
minirest:return({error, missing_required_params}).
|
||||||
|
|
||||||
delete(#{filename := Filename}, _Params) ->
|
delete(#{filename := Filename}, _Params) ->
|
||||||
FullFilename = filename:join([emqx:get_env(data_dir), Filename]),
|
FullFilename = filename:join([emqx:get_env(data_dir), Filename]),
|
||||||
case file:delete(FullFilename) of
|
case file:delete(FullFilename) of
|
||||||
ok ->
|
ok ->
|
||||||
return();
|
minirest:return();
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return({error, Reason})
|
minirest:return({error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
-module(emqx_mgmt_api_listeners).
|
-module(emqx_mgmt_api_listeners).
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_listeners,
|
-rest_api(#{name => list_listeners,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/listeners/",
|
path => "/listeners/",
|
||||||
|
@ -46,18 +44,18 @@
|
||||||
|
|
||||||
%% List listeners on a node.
|
%% List listeners on a node.
|
||||||
list(#{node := Node}, _Params) ->
|
list(#{node := Node}, _Params) ->
|
||||||
return({ok, format(emqx_mgmt:list_listeners(Node))});
|
minirest:return({ok, format(emqx_mgmt:list_listeners(Node))});
|
||||||
|
|
||||||
%% List listeners in the cluster.
|
%% List listeners in the cluster.
|
||||||
list(_Binding, _Params) ->
|
list(_Binding, _Params) ->
|
||||||
return({ok, [#{node => Node, listeners => format(Listeners)}
|
minirest:return({ok, [#{node => Node, listeners => format(Listeners)}
|
||||||
|| {Node, Listeners} <- emqx_mgmt:list_listeners()]}).
|
|| {Node, Listeners} <- emqx_mgmt:list_listeners()]}).
|
||||||
|
|
||||||
%% Restart listeners on a node.
|
%% Restart listeners on a node.
|
||||||
restart(#{node := Node, identifier := Identifier}, _Params) ->
|
restart(#{node := Node, identifier := Identifier}, _Params) ->
|
||||||
case emqx_mgmt:restart_listener(Node, Identifier) of
|
case emqx_mgmt:restart_listener(Node, Identifier) of
|
||||||
ok -> return({ok, "Listener restarted."});
|
ok -> minirest:return({ok, "Listener restarted."});
|
||||||
{error, Error} -> return({error, Error})
|
{error, Error} -> minirest:return({error, Error})
|
||||||
end;
|
end;
|
||||||
|
|
||||||
%% Restart listeners in the cluster.
|
%% Restart listeners in the cluster.
|
||||||
|
@ -66,8 +64,8 @@ restart(#{identifier := <<"http", _/binary>>}, _Params) ->
|
||||||
restart(#{identifier := Identifier}, _Params) ->
|
restart(#{identifier := Identifier}, _Params) ->
|
||||||
Results = [{Node, emqx_mgmt:restart_listener(Node, Identifier)} || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
Results = [{Node, emqx_mgmt:restart_listener(Node, Identifier)} || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
||||||
case lists:filter(fun({_, Result}) -> Result =/= ok end, Results) of
|
case lists:filter(fun({_, Result}) -> Result =/= ok end, Results) of
|
||||||
[] -> return(ok);
|
[] -> minirest:return(ok);
|
||||||
Errors -> return({error, {restart, Errors}})
|
Errors -> minirest:return({error, {restart, Errors}})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format(Listeners) when is_list(Listeners) ->
|
format(Listeners) when is_list(Listeners) ->
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
-module(emqx_mgmt_api_metrics).
|
-module(emqx_mgmt_api_metrics).
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_all_metrics,
|
-rest_api(#{name => list_all_metrics,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/metrics",
|
path => "/metrics",
|
||||||
|
@ -33,12 +31,12 @@
|
||||||
-export([list/2]).
|
-export([list/2]).
|
||||||
|
|
||||||
list(Bindings, _Params) when map_size(Bindings) == 0 ->
|
list(Bindings, _Params) when map_size(Bindings) == 0 ->
|
||||||
return({ok, [#{node => Node, metrics => maps:from_list(Metrics)}
|
minirest:return({ok, [#{node => Node, metrics => maps:from_list(Metrics)}
|
||||||
|| {Node, Metrics} <- emqx_mgmt:get_metrics()]});
|
|| {Node, Metrics} <- emqx_mgmt:get_metrics()]});
|
||||||
|
|
||||||
list(#{node := Node}, _Params) ->
|
list(#{node := Node}, _Params) ->
|
||||||
case emqx_mgmt:get_metrics(Node) of
|
case emqx_mgmt:get_metrics(Node) of
|
||||||
{error, Reason} -> return({error, Reason});
|
{error, Reason} -> minirest:return({error, Reason});
|
||||||
Metrics -> return({ok, maps:from_list(Metrics)})
|
Metrics -> minirest:return({ok, maps:from_list(Metrics)})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
-module(emqx_mgmt_api_nodes).
|
-module(emqx_mgmt_api_nodes).
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_nodes,
|
-rest_api(#{name => list_nodes,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/nodes/",
|
path => "/nodes/",
|
||||||
|
@ -35,10 +33,10 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
list(_Bindings, _Params) ->
|
list(_Bindings, _Params) ->
|
||||||
return({ok, [format(Node, Info) || {Node, Info} <- emqx_mgmt:list_nodes()]}).
|
minirest:return({ok, [format(Node, Info) || {Node, Info} <- emqx_mgmt:list_nodes()]}).
|
||||||
|
|
||||||
get(#{node := Node}, _Params) ->
|
get(#{node := Node}, _Params) ->
|
||||||
return({ok, emqx_mgmt:lookup_node(Node)}).
|
minirest:return({ok, emqx_mgmt:lookup_node(Node)}).
|
||||||
|
|
||||||
format(Node, {error, Reason}) -> #{node => Node, error => Reason};
|
format(Node, {error, Reason}) -> #{node => Node, error => Reason};
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_all_plugins,
|
-rest_api(#{name => list_all_plugins,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/plugins/",
|
path => "/plugins/",
|
||||||
|
@ -71,36 +69,36 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
list(#{node := Node}, _Params) ->
|
list(#{node := Node}, _Params) ->
|
||||||
return({ok, [format(Plugin) || Plugin <- emqx_mgmt:list_plugins(Node)]});
|
minirest:return({ok, [format(Plugin) || Plugin <- emqx_mgmt:list_plugins(Node)]});
|
||||||
|
|
||||||
list(_Bindings, _Params) ->
|
list(_Bindings, _Params) ->
|
||||||
return({ok, [format({Node, Plugins}) || {Node, Plugins} <- emqx_mgmt:list_plugins()]}).
|
minirest:return({ok, [format({Node, Plugins}) || {Node, Plugins} <- emqx_mgmt:list_plugins()]}).
|
||||||
|
|
||||||
load(#{node := Node, plugin := Plugin}, _Params) ->
|
load(#{node := Node, plugin := Plugin}, _Params) ->
|
||||||
return(emqx_mgmt:load_plugin(Node, Plugin)).
|
minirest:return(emqx_mgmt:load_plugin(Node, Plugin)).
|
||||||
|
|
||||||
unload(#{node := Node, plugin := Plugin}, _Params) ->
|
unload(#{node := Node, plugin := Plugin}, _Params) ->
|
||||||
return(emqx_mgmt:unload_plugin(Node, Plugin));
|
minirest:return(emqx_mgmt:unload_plugin(Node, Plugin));
|
||||||
|
|
||||||
unload(#{plugin := Plugin}, _Params) ->
|
unload(#{plugin := Plugin}, _Params) ->
|
||||||
Results = [emqx_mgmt:unload_plugin(Node, Plugin) || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
Results = [emqx_mgmt:unload_plugin(Node, Plugin) || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
||||||
case lists:filter(fun(Item) -> Item =/= ok end, Results) of
|
case lists:filter(fun(Item) -> Item =/= ok end, Results) of
|
||||||
[] ->
|
[] ->
|
||||||
return(ok);
|
minirest:return(ok);
|
||||||
Errors ->
|
Errors ->
|
||||||
return(lists:last(Errors))
|
minirest:return(lists:last(Errors))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
reload(#{node := Node, plugin := Plugin}, _Params) ->
|
reload(#{node := Node, plugin := Plugin}, _Params) ->
|
||||||
return(emqx_mgmt:reload_plugin(Node, Plugin));
|
minirest:return(emqx_mgmt:reload_plugin(Node, Plugin));
|
||||||
|
|
||||||
reload(#{plugin := Plugin}, _Params) ->
|
reload(#{plugin := Plugin}, _Params) ->
|
||||||
Results = [emqx_mgmt:reload_plugin(Node, Plugin) || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
Results = [emqx_mgmt:reload_plugin(Node, Plugin) || {Node, _Info} <- emqx_mgmt:list_nodes()],
|
||||||
case lists:filter(fun(Item) -> Item =/= ok end, Results) of
|
case lists:filter(fun(Item) -> Item =/= ok end, Results) of
|
||||||
[] ->
|
[] ->
|
||||||
return(ok);
|
minirest:return(ok);
|
||||||
Errors ->
|
Errors ->
|
||||||
return(lists:last(Errors))
|
minirest:return(lists:last(Errors))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format({Node, Plugins}) ->
|
format({Node, Plugins}) ->
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
, get_value/3
|
, get_value/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => mqtt_subscribe,
|
-rest_api(#{name => mqtt_subscribe,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
path => "/mqtt/subscribe",
|
path => "/mqtt/subscribe",
|
||||||
|
@ -73,7 +71,7 @@
|
||||||
subscribe(_Bindings, Params) ->
|
subscribe(_Bindings, Params) ->
|
||||||
logger:debug("API subscribe Params:~p", [Params]),
|
logger:debug("API subscribe Params:~p", [Params]),
|
||||||
{ClientId, Topic, QoS} = parse_subscribe_params(Params),
|
{ClientId, Topic, QoS} = parse_subscribe_params(Params),
|
||||||
return(do_subscribe(ClientId, Topic, QoS)).
|
minirest:return(do_subscribe(ClientId, Topic, QoS)).
|
||||||
|
|
||||||
publish(_Bindings, Params) ->
|
publish(_Bindings, Params) ->
|
||||||
logger:debug("API publish Params:~p", [Params]),
|
logger:debug("API publish Params:~p", [Params]),
|
||||||
|
@ -81,33 +79,33 @@ publish(_Bindings, Params) ->
|
||||||
case do_publish(ClientId, Topic, Qos, Retain, Payload) of
|
case do_publish(ClientId, Topic, Qos, Retain, Payload) of
|
||||||
{ok, MsgIds} ->
|
{ok, MsgIds} ->
|
||||||
case get_value(<<"return">>, Params, undefined) of
|
case get_value(<<"return">>, Params, undefined) of
|
||||||
undefined -> return(ok);
|
undefined -> minirest:return(ok);
|
||||||
_Val ->
|
_Val ->
|
||||||
case get_value(<<"topics">>, Params, undefined) of
|
case get_value(<<"topics">>, Params, undefined) of
|
||||||
undefined -> return({ok, #{msgid => lists:last(MsgIds)}});
|
undefined -> minirest:return({ok, #{msgid => lists:last(MsgIds)}});
|
||||||
_ -> return({ok, #{msgids => MsgIds}})
|
_ -> minirest:return({ok, #{msgids => MsgIds}})
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
Result ->
|
Result ->
|
||||||
return(Result)
|
minirest:return(Result)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
unsubscribe(_Bindings, Params) ->
|
unsubscribe(_Bindings, Params) ->
|
||||||
logger:debug("API unsubscribe Params:~p", [Params]),
|
logger:debug("API unsubscribe Params:~p", [Params]),
|
||||||
{ClientId, Topic} = parse_unsubscribe_params(Params),
|
{ClientId, Topic} = parse_unsubscribe_params(Params),
|
||||||
return(do_unsubscribe(ClientId, Topic)).
|
minirest:return(do_unsubscribe(ClientId, Topic)).
|
||||||
|
|
||||||
subscribe_batch(_Bindings, Params) ->
|
subscribe_batch(_Bindings, Params) ->
|
||||||
logger:debug("API subscribe batch Params:~p", [Params]),
|
logger:debug("API subscribe batch Params:~p", [Params]),
|
||||||
return({ok, loop_subscribe(Params)}).
|
minirest:return({ok, loop_subscribe(Params)}).
|
||||||
|
|
||||||
publish_batch(_Bindings, Params) ->
|
publish_batch(_Bindings, Params) ->
|
||||||
logger:debug("API publish batch Params:~p", [Params]),
|
logger:debug("API publish batch Params:~p", [Params]),
|
||||||
return({ok, loop_publish(Params)}).
|
minirest:return({ok, loop_publish(Params)}).
|
||||||
|
|
||||||
unsubscribe_batch(_Bindings, Params) ->
|
unsubscribe_batch(_Bindings, Params) ->
|
||||||
logger:debug("API unsubscribe batch Params:~p", [Params]),
|
logger:debug("API unsubscribe batch Params:~p", [Params]),
|
||||||
return({ok, loop_unsubscribe(Params)}).
|
minirest:return({ok, loop_unsubscribe(Params)}).
|
||||||
|
|
||||||
loop_subscribe(Params) ->
|
loop_subscribe(Params) ->
|
||||||
loop_subscribe(Params, []).
|
loop_subscribe(Params, []).
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_routes,
|
-rest_api(#{name => list_routes,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/routes/",
|
path => "/routes/",
|
||||||
|
@ -37,11 +35,11 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
||||||
return({ok, emqx_mgmt_api:paginate(emqx_route, Params, fun format/1)}).
|
minirest:return({ok, emqx_mgmt_api:paginate(emqx_route, Params, fun format/1)}).
|
||||||
|
|
||||||
lookup(#{topic := Topic}, _Params) ->
|
lookup(#{topic := Topic}, _Params) ->
|
||||||
Topic1 = emqx_mgmt_util:urldecode(Topic),
|
Topic1 = emqx_mgmt_util:urldecode(Topic),
|
||||||
return({ok, [format(R) || R <- emqx_mgmt:lookup_routes(Topic1)]}).
|
minirest:return({ok, [format(R) || R <- emqx_mgmt:lookup_routes(Topic1)]}).
|
||||||
format(#route{topic = Topic, dest = {_, Node}}) ->
|
format(#route{topic = Topic, dest = {_, Node}}) ->
|
||||||
#{topic => Topic, node => Node};
|
#{topic => Topic, node => Node};
|
||||||
format(#route{topic = Topic, dest = Node}) ->
|
format(#route{topic = Topic, dest = Node}) ->
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
-module(emqx_mgmt_api_stats).
|
-module(emqx_mgmt_api_stats).
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-rest_api(#{name => list_stats,
|
-rest_api(#{name => list_stats,
|
||||||
method => 'GET',
|
method => 'GET',
|
||||||
path => "/stats/",
|
path => "/stats/",
|
||||||
|
@ -36,12 +34,12 @@
|
||||||
|
|
||||||
%% List stats of all nodes
|
%% List stats of all nodes
|
||||||
list(Bindings, _Params) when map_size(Bindings) == 0 ->
|
list(Bindings, _Params) when map_size(Bindings) == 0 ->
|
||||||
return({ok, [#{node => Node, stats => maps:from_list(Stats)}
|
minirest:return({ok, [#{node => Node, stats => maps:from_list(Stats)}
|
||||||
|| {Node, Stats} <- emqx_mgmt:get_stats()]}).
|
|| {Node, Stats} <- emqx_mgmt:get_stats()]}).
|
||||||
|
|
||||||
%% List stats of a node
|
%% List stats of a node
|
||||||
lookup(#{node := Node}, _Params) ->
|
lookup(#{node := Node}, _Params) ->
|
||||||
case emqx_mgmt:get_stats(Node) of
|
case emqx_mgmt:get_stats(Node) of
|
||||||
{error, Reason} -> return({error, Reason});
|
{error, Reason} -> minirest:return({error, Reason});
|
||||||
Stats -> return({ok, maps:from_list(Stats)})
|
Stats -> minirest:return({ok, maps:from_list(Stats)})
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
|
|
||||||
-import(minirest, [return/1]).
|
|
||||||
|
|
||||||
-define(SUBS_QS_SCHEMA, {emqx_suboption,
|
-define(SUBS_QS_SCHEMA, {emqx_suboption,
|
||||||
[{<<"clientid">>, binary},
|
[{<<"clientid">>, binary},
|
||||||
{<<"topic">>, binary},
|
{<<"topic">>, binary},
|
||||||
|
@ -65,9 +63,9 @@
|
||||||
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
list(Bindings, Params) when map_size(Bindings) == 0 ->
|
||||||
case proplists:get_value(<<"topic">>, Params) of
|
case proplists:get_value(<<"topic">>, Params) of
|
||||||
undefined ->
|
undefined ->
|
||||||
return({ok, emqx_mgmt_api:cluster_query(Params, ?SUBS_QS_SCHEMA, ?query_fun)});
|
minirest:return({ok, emqx_mgmt_api:cluster_query(Params, ?SUBS_QS_SCHEMA, ?query_fun)});
|
||||||
Topic ->
|
Topic ->
|
||||||
return({ok, emqx_mgmt:list_subscriptions_via_topic(emqx_mgmt_util:urldecode(Topic), ?format_fun)})
|
minirest:return({ok, emqx_mgmt:list_subscriptions_via_topic(emqx_mgmt_util:urldecode(Topic), ?format_fun)})
|
||||||
end;
|
end;
|
||||||
|
|
||||||
list(#{node := Node} = Bindings, Params) ->
|
list(#{node := Node} = Bindings, Params) ->
|
||||||
|
@ -75,22 +73,22 @@ list(#{node := Node} = Bindings, Params) ->
|
||||||
undefined ->
|
undefined ->
|
||||||
case Node =:= node() of
|
case Node =:= node() of
|
||||||
true ->
|
true ->
|
||||||
return({ok, emqx_mgmt_api:node_query(Node, Params, ?SUBS_QS_SCHEMA, ?query_fun)});
|
minirest:return({ok, emqx_mgmt_api:node_query(Node, Params, ?SUBS_QS_SCHEMA, ?query_fun)});
|
||||||
false ->
|
false ->
|
||||||
case rpc:call(Node, ?MODULE, list, [Bindings, Params]) of
|
case rpc:call(Node, ?MODULE, list, [Bindings, Params]) of
|
||||||
{badrpc, Reason} -> return({error, Reason});
|
{badrpc, Reason} -> minirest:return({error, Reason});
|
||||||
Res -> Res
|
Res -> Res
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
Topic ->
|
Topic ->
|
||||||
return({ok, emqx_mgmt:list_subscriptions_via_topic(Node, emqx_mgmt_util:urldecode(Topic), ?format_fun)})
|
minirest:return({ok, emqx_mgmt:list_subscriptions_via_topic(Node, emqx_mgmt_util:urldecode(Topic), ?format_fun)})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
lookup(#{node := Node, clientid := ClientId}, _Params) ->
|
lookup(#{node := Node, clientid := ClientId}, _Params) ->
|
||||||
return({ok, format(emqx_mgmt:lookup_subscriptions(Node, emqx_mgmt_util:urldecode(ClientId)))});
|
minirest:return({ok, format(emqx_mgmt:lookup_subscriptions(Node, emqx_mgmt_util:urldecode(ClientId)))});
|
||||||
|
|
||||||
lookup(#{clientid := ClientId}, _Params) ->
|
lookup(#{clientid := ClientId}, _Params) ->
|
||||||
return({ok, format(emqx_mgmt:lookup_subscriptions(emqx_mgmt_util:urldecode(ClientId)))}).
|
minirest:return({ok, format(emqx_mgmt:lookup_subscriptions(emqx_mgmt_util:urldecode(ClientId)))}).
|
||||||
|
|
||||||
format(Items) when is_list(Items) ->
|
format(Items) when is_list(Items) ->
|
||||||
[format(Item) || Item <- Items];
|
[format(Item) || Item <- Items];
|
||||||
|
|
Loading…
Reference in New Issue