fix(mgmt): return null instead of "undefined" string
This commit is contained in:
parent
ebe8b3fd20
commit
1867b86bad
|
@ -862,10 +862,12 @@ format_channel_info({_, ClientInfo0, ClientStats}) ->
|
||||||
],
|
],
|
||||||
TimesKeys = [created_at, connected_at, disconnected_at],
|
TimesKeys = [created_at, connected_at, disconnected_at],
|
||||||
%% format timestamp to rfc3339
|
%% format timestamp to rfc3339
|
||||||
|
result_format_undefined_to_null(
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun result_format_time_fun/2,
|
fun result_format_time_fun/2,
|
||||||
maps:without(RemoveList, ClientInfoMap),
|
maps:without(RemoveList, ClientInfoMap),
|
||||||
TimesKeys
|
TimesKeys
|
||||||
|
)
|
||||||
).
|
).
|
||||||
|
|
||||||
%% format func helpers
|
%% format func helpers
|
||||||
|
@ -884,6 +886,15 @@ result_format_time_fun(Key, NClientInfoMap) ->
|
||||||
NClientInfoMap
|
NClientInfoMap
|
||||||
end.
|
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()}.
|
-spec peername_dispart(emqx_types:peername()) -> {binary(), inet:port_number()}.
|
||||||
peername_dispart({Addr, Port}) ->
|
peername_dispart({Addr, Port}) ->
|
||||||
AddrBinary = list_to_binary(inet:ntoa(Addr)),
|
AddrBinary = list_to_binary(inet:ntoa(Addr)),
|
||||||
|
|
Loading…
Reference in New Issue