fix: enable param is atom

This commit is contained in:
Stefan Strigler 2023-10-18 17:06:48 +02:00 committed by Zaiming (Stone) Shi
parent abcae6b509
commit 2b66018d3b
1 changed files with 13 additions and 19 deletions

View File

@ -391,11 +391,7 @@ schema("/bridges_v2_probe") ->
'/bridges_v2/:id/enable/:enable'(put, #{bindings := #{id := Id, enable := Enable}}) ->
?TRY_PARSE_ID(
Id,
case enable_func(Enable) of
invalid ->
?NOT_FOUND(<<"Invalid operation">>);
OperFunc ->
case emqx_bridge_v2:disable_enable(OperFunc, BridgeType, BridgeName) of
case emqx_bridge_v2:disable_enable(enable_func(Enable), BridgeType, BridgeName) of
{ok, _} ->
?NO_CONTENT;
{error, {pre_config_update, _, not_found}} ->
@ -407,7 +403,6 @@ schema("/bridges_v2_probe") ->
{error, Reason} ->
?INTERNAL_ERROR(Reason)
end
end
).
'/bridges_v2/:id/:operation'(post, #{
@ -728,9 +723,8 @@ create_or_update_bridge(BridgeType, BridgeName, Conf, HttpStatusCode) ->
?BAD_REQUEST(map_to_json(redact(Reason)))
end.
enable_func(<<"true">>) -> enable;
enable_func(<<"false">>) -> disable;
enable_func(_) -> invalid.
enable_func(true) -> enable;
enable_func(false) -> disable.
filter_out_request_body(Conf) ->
ExtraConfs = [