fix(emqx_bridge): remove unreachable code paths

This commit is contained in:
Stefan Strigler 2023-03-09 15:17:32 +01:00
parent dba95ec0fa
commit 478601ee41
1 changed files with 5 additions and 13 deletions

View File

@ -478,17 +478,13 @@ schema("/bridges_probe") ->
}. }.
'/bridges'(post, #{body := #{<<"type">> := BridgeType, <<"name">> := BridgeName} = Conf0}) -> '/bridges'(post, #{body := #{<<"type">> := BridgeType, <<"name">> := BridgeName} = Conf0}) ->
Conf = filter_out_request_body(Conf0),
case emqx_bridge:lookup(BridgeType, BridgeName) of case emqx_bridge:lookup(BridgeType, BridgeName) of
{ok, _} -> {ok, _} ->
{400, error_msg('ALREADY_EXISTS', <<"bridge already exists">>)}; {400, error_msg('ALREADY_EXISTS', <<"bridge already exists">>)};
{error, not_found} -> {error, not_found} ->
case emqx_bridge:create(BridgeType, BridgeName, Conf) of Conf = filter_out_request_body(Conf0),
{ok, _} -> {ok, _} = emqx_bridge:create(BridgeType, BridgeName, Conf),
lookup_from_all_nodes(BridgeType, BridgeName, 201); lookup_from_all_nodes(BridgeType, BridgeName, 201)
{error, Reason} ->
?BAD_REQUEST(Reason)
end
end; end;
'/bridges'(get, _Params) -> '/bridges'(get, _Params) ->
{200, {200,
@ -507,12 +503,8 @@ schema("/bridges_probe") ->
{ok, _} -> {ok, _} ->
RawConf = emqx:get_raw_config([bridges, BridgeType, BridgeName], #{}), RawConf = emqx:get_raw_config([bridges, BridgeType, BridgeName], #{}),
Conf = deobfuscate(Conf1, RawConf), Conf = deobfuscate(Conf1, RawConf),
case emqx_bridge:create(BridgeType, BridgeName, Conf) of {ok, _} = emqx_bridge:create(BridgeType, BridgeName, Conf),
{ok, _} -> lookup_from_all_nodes(BridgeType, BridgeName, 200);
lookup_from_all_nodes(BridgeType, BridgeName, 200);
{error, Reason} ->
?BAD_REQUEST(Reason)
end;
{error, not_found} -> {error, not_found} ->
?BRIDGE_NOT_FOUND(BridgeType, BridgeName) ?BRIDGE_NOT_FOUND(BridgeType, BridgeName)
end end