sdlan/src/http_handler/node_handler.erl
2026-04-02 14:26:48 +08:00

26 lines
897 B
Erlang

%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 09. 4月 2024 14:28
%%%-------------------------------------------------------------------
-module(node_handler).
-author("anlicheng").
%% API
-export([handle_request/4]).
handle_request("POST", "/node/disable", _, #{<<"network_id">> := NetworkId, <<"client_id">> := ClientId}) when NetworkId > 0 ->
case sdlan_network:get_pid(NetworkId) of
undefined ->
{ok, 200, sdlan_util:json_error(-1, <<"network not found">>)};
Pid ->
sdlan_network:disable_client(Pid, ClientId),
{ok, 200, sdlan_util:json_data(<<"success">>)}
end;
handle_request(_, Path, _, _) ->
Path1 = list_to_binary(Path),
{ok, 200, sdlan_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.