34 lines
1.1 KiB
Erlang
34 lines
1.1 KiB
Erlang
%%%-------------------------------------------------------------------
|
|
%%% @author licheng5
|
|
%%% @copyright (C) 2020, <COMPANY>
|
|
%%% @doc
|
|
%%%
|
|
%%% @end
|
|
%%% Created : 26. 4月 2020 3:36 下午
|
|
%%%-------------------------------------------------------------------
|
|
-module(api_handler).
|
|
-author("licheng5").
|
|
|
|
%% API
|
|
-export([handle_request/4]).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% helper methods
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% 重新加载对应的主机信息
|
|
handle_request("POST", "/test/auth_token", _, PostParams) ->
|
|
logger:debug("[test_handler] get post params: ~p", [PostParams]),
|
|
[Id | _] = network_bo:get_all_networks(),
|
|
Data = #{
|
|
<<"network_id">> => Id
|
|
},
|
|
{ok, 200, sdlan_util:json_data(Data)};
|
|
|
|
handle_request(_, Path, _, _) ->
|
|
Path1 = list_to_binary(Path),
|
|
{ok, 200, sdlan_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% helper methods
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |