fix(API): return 400 if delete failed

This commit is contained in:
Shawn 2021-08-05 09:25:49 +08:00
parent 139712fc94
commit eee98a5803
1 changed files with 7 additions and 2 deletions

View File

@ -40,6 +40,8 @@
}
}).
-define(ERR_MSG(MSG), io_lib:format("~p", [MSG])).
api_spec() ->
{config_apis(), []}.
@ -92,8 +94,11 @@ config(get, Req) ->
config(delete, Req) ->
%% TODO: remove the config specified by the query string param 'conf_path'
emqx_config:remove(conf_path_from_querystr(Req)),
{200};
case emqx_config:remove(conf_path_from_querystr(Req)) of
ok -> {200};
{error, Reason} ->
{400, ?ERR_MSG(Reason)}
end;
config(put, Req) ->
Path = [binary_to_atom(Key, latin1) || Key <- conf_path_from_querystr(Req)],