fix(API): return 400 if delete failed
This commit is contained in:
parent
139712fc94
commit
eee98a5803
|
@ -40,6 +40,8 @@
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
-define(ERR_MSG(MSG), io_lib:format("~p", [MSG])).
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
{config_apis(), []}.
|
{config_apis(), []}.
|
||||||
|
|
||||||
|
@ -92,8 +94,11 @@ config(get, Req) ->
|
||||||
|
|
||||||
config(delete, Req) ->
|
config(delete, Req) ->
|
||||||
%% TODO: remove the config specified by the query string param 'conf_path'
|
%% TODO: remove the config specified by the query string param 'conf_path'
|
||||||
emqx_config:remove(conf_path_from_querystr(Req)),
|
case emqx_config:remove(conf_path_from_querystr(Req)) of
|
||||||
{200};
|
ok -> {200};
|
||||||
|
{error, Reason} ->
|
||||||
|
{400, ?ERR_MSG(Reason)}
|
||||||
|
end;
|
||||||
|
|
||||||
config(put, Req) ->
|
config(put, Req) ->
|
||||||
Path = [binary_to_atom(Key, latin1) || Key <- conf_path_from_querystr(Req)],
|
Path = [binary_to_atom(Key, latin1) || Key <- conf_path_from_querystr(Req)],
|
||||||
|
|
Loading…
Reference in New Issue