fix(mgmt): return null instead of "undefined" string

This commit is contained in:
JianBo He 2022-05-12 18:01:10 +08:00
parent ebe8b3fd20
commit 1867b86bad
1 changed files with 15 additions and 4 deletions

View File

@ -862,10 +862,12 @@ format_channel_info({_, ClientInfo0, ClientStats}) ->
],
TimesKeys = [created_at, connected_at, disconnected_at],
%% format timestamp to rfc3339
lists:foldl(
fun result_format_time_fun/2,
maps:without(RemoveList, ClientInfoMap),
TimesKeys
result_format_undefined_to_null(
lists:foldl(
fun result_format_time_fun/2,
maps:without(RemoveList, ClientInfoMap),
TimesKeys
)
).
%% format func helpers
@ -884,6 +886,15 @@ result_format_time_fun(Key, NClientInfoMap) ->
NClientInfoMap
end.
result_format_undefined_to_null(Map) ->
maps:map(
fun
(_, undefined) -> null;
(_, V) -> V
end,
Map
).
-spec peername_dispart(emqx_types:peername()) -> {binary(), inet:port_number()}.
peername_dispart({Addr, Port}) ->
AddrBinary = list_to_binary(inet:ntoa(Addr)),