Просмотр исходного кода

chore: use put instead of post to update setting

zhongwencool 2 лет назад
Родитель
Сommit
a8b9b6f27f

+ 3 - 2
lib-ee/emqx_license/src/emqx_license_http_api.erl

@@ -54,6 +54,7 @@ schema("/license") ->
                 )
             }
         },
+        %% FIXME: It's a update action, should use put instead of post in 5.2.0
         post => #{
             tags => ?LICENSE_TAGS,
             summary => <<"Update license key">>,
@@ -93,7 +94,7 @@ schema("/license/setting") ->
                 200 => setting()
             }
         },
-        post => #{
+        put => #{
             tags => ?LICENSE_TAGS,
             summary => <<"Update license setting">>,
             description => ?DESC("desc_license_setting_api"),
@@ -144,7 +145,7 @@ error_msg(Code, Msg) ->
 
 '/license/setting'(get, _Params) ->
     {200, maps:remove(<<"key">>, emqx_config:get_raw([license]))};
-'/license/setting'(post, #{body := Setting}) ->
+'/license/setting'(put, #{body := Setting}) ->
     case emqx_license:update_setting(Setting) of
         {error, Error} ->
             ?SLOG(error, #{

+ 3 - 3
lib-ee/emqx_license/test/emqx_license_http_api_SUITE.erl

@@ -186,7 +186,7 @@ t_license_setting(_Config) ->
     %% update
     Low = <<"50%">>,
     High = <<"55%">>,
-    UpdateRes = request(post, uri(["license", "setting"]), #{
+    UpdateRes = request(put, uri(["license", "setting"]), #{
         <<"connection_low_watermark">> => Low,
         <<"connection_high_watermark">> => High
     }),
@@ -197,14 +197,14 @@ t_license_setting(_Config) ->
     %% update bad setting low >= high
     ?assertMatch(
         {ok, 400, _},
-        request(post, uri(["license", "setting"]), #{
+        request(put, uri(["license", "setting"]), #{
             <<"connection_low_watermark">> => <<"50%">>,
             <<"connection_high_watermark">> => <<"50%">>
         })
     ),
     ?assertMatch(
         {ok, 400, _},
-        request(post, uri(["license", "setting"]), #{
+        request(put, uri(["license", "setting"]), #{
             <<"connection_low_watermark">> => <<"51%">>,
             <<"connection_high_watermark">> => <<"50%">>
         })