Merge pull request #7813 from DDDHuang/bridge_api_bad_format

fix: bridge api response bad node name format
This commit is contained in:
zhongwencool 2022-04-29 09:12:22 +08:00 committed by GitHub
commit c7241f2abc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -392,7 +392,7 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
'/bridges'(get, _Params) -> '/bridges'(get, _Params) ->
{200, {200,
zip_bridges([ zip_bridges([
[format_resp(Data) || Data <- emqx_bridge_proto_v1:list_bridges(Node)] [format_resp(Data, Node) || Data <- emqx_bridge_proto_v1:list_bridges(Node)]
|| Node <- mria_mnesia:running_nodes() || Node <- mria_mnesia:running_nodes()
])}. ])}.
@ -619,17 +619,23 @@ aggregate_metrics(AllMetrics) ->
AllMetrics AllMetrics
). ).
format_resp(#{ format_resp(Data) ->
format_resp(Data, node()).
format_resp(
#{
type := Type, type := Type,
name := BridgeName, name := BridgeName,
raw_config := RawConf, raw_config := RawConf,
resource_data := #{status := Status, metrics := Metrics} resource_data := #{status := Status, metrics := Metrics}
}) -> },
Node
) ->
RawConfFull = fill_defaults(Type, RawConf), RawConfFull = fill_defaults(Type, RawConf),
RawConfFull#{ RawConfFull#{
type => Type, type => Type,
name => maps:get(<<"name">>, RawConf, BridgeName), name => maps:get(<<"name">>, RawConf, BridgeName),
node => node(), node => Node,
status => Status, status => Status,
metrics => format_metrics(Metrics) metrics => format_metrics(Metrics)
}. }.