Explorar o código

fix: return 204 instead of 200 if there's no body content

Stefan Strigler %!s(int64=3) %!d(string=hai) anos
pai
achega
4e12a44ee6
Modificáronse 1 ficheiros con 6 adicións e 6 borrados
  1. 6 6
      apps/emqx_bridge/src/emqx_bridge_api.erl

+ 6 - 6
apps/emqx_bridge/src/emqx_bridge_api.erl

@@ -378,7 +378,7 @@ schema("/bridges/:id/metrics/reset") ->
             description => ?DESC("desc_api6"),
             description => ?DESC("desc_api6"),
             parameters => [param_path_id()],
             parameters => [param_path_id()],
             responses => #{
             responses => #{
-                200 => <<"Reset success">>,
+                204 => <<"Reset success">>,
                 400 => error_schema(['BAD_REQUEST'], "RPC Call Failed")
                 400 => error_schema(['BAD_REQUEST'], "RPC Call Failed")
             }
             }
         }
         }
@@ -412,7 +412,7 @@ schema("/bridges/:id/:operation") ->
                 param_path_operation_cluster()
                 param_path_operation_cluster()
             ],
             ],
             responses => #{
             responses => #{
-                200 => <<"Operation success">>,
+                204 => <<"Operation success">>,
                 503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable"),
                 503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable"),
                 400 => error_schema('INVALID_ID', "Bad bridge ID")
                 400 => error_schema('INVALID_ID', "Bad bridge ID")
             }
             }
@@ -431,7 +431,7 @@ schema("/nodes/:node/bridges/:id/:operation") ->
                 param_path_operation_on_node()
                 param_path_operation_on_node()
             ],
             ],
             responses => #{
             responses => #{
-                200 => <<"Operation success">>,
+                204 => <<"Operation success">>,
                 400 => error_schema('INVALID_ID', "Bad bridge ID"),
                 400 => error_schema('INVALID_ID', "Bad bridge ID"),
                 403 => error_schema('FORBIDDEN_REQUEST', "forbidden operation"),
                 403 => error_schema('FORBIDDEN_REQUEST', "forbidden operation"),
                 503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable")
                 503 => error_schema('SERVICE_UNAVAILABLE', "Service unavailable")
@@ -535,7 +535,7 @@ schema("/bridges_probe") ->
                 emqx_bridge_resource:resource_id(BridgeType, BridgeName)
                 emqx_bridge_resource:resource_id(BridgeType, BridgeName)
             )
             )
         of
         of
-            ok -> {200, <<"Reset success">>};
+            ok -> {204};
             Reason -> {400, error_msg('BAD_REQUEST', Reason)}
             Reason -> {400, error_msg('BAD_REQUEST', Reason)}
         end
         end
     ).
     ).
@@ -660,7 +660,7 @@ operation_to_all_nodes(Nodes, OperFunc, BridgeType, BridgeName) ->
         end,
         end,
     case is_ok(emqx_bridge_proto_v1:RpcFunc(Nodes, BridgeType, BridgeName)) of
     case is_ok(emqx_bridge_proto_v1:RpcFunc(Nodes, BridgeType, BridgeName)) of
         {ok, _} ->
         {ok, _} ->
-            {200};
+            {204};
         {error, [timeout | _]} ->
         {error, [timeout | _]} ->
             {503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
             {503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
         {error, ErrL} ->
         {error, ErrL} ->
@@ -905,7 +905,7 @@ call_operation(Node, OperFunc, BridgeType, BridgeName) ->
                 )
                 )
             of
             of
                 ok ->
                 ok ->
-                    {200};
+                    {204};
                 {error, timeout} ->
                 {error, timeout} ->
                     {503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
                     {503, error_msg('SERVICE_UNAVAILABLE', <<"request timeout">>)};
                 {error, {start_pool_failed, Name, Reason}} ->
                 {error, {start_pool_failed, Name, Reason}} ->