diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c96c2348..22d681a81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,6 @@ set(NEURON_SOURCES plugins/restful/otel_handle.c plugins/restful/cid_handle.c plugins/restful/tpy_handle.c - plugins/restful/system_handle.c plugins/restful/datalayers_handle.c plugins/restful/rest.c plugins/restful/user.c diff --git a/plugins/restful/handle.c b/plugins/restful/handle.c index 6c2526df3..ccacb7279 100644 --- a/plugins/restful/handle.c +++ b/plugins/restful/handle.c @@ -38,7 +38,6 @@ #include "plugin_handle.h" #include "rw_handle.h" #include "scan_handle.h" -#include "system_handle.h" #include "tpy_handle.h" #include "utils/http.h" #include "version_handle.h" @@ -146,9 +145,6 @@ static struct neu_http_handler cors_handler[] = { { .url = "/api/v2/tpy", }, - { - .url = "/api/v2/system/ctl", - }, { .url = "/api/v2/users", }, @@ -552,12 +548,6 @@ static struct neu_http_handler rest_handlers[] = { .url = "/api/v2/otel", .value.handler = handle_otel_get, }, - { - .method = NEU_HTTP_METHOD_POST, - .type = NEU_HTTP_HANDLER_FUNCTION, - .url = "/api/v2/system/ctl", - .value.handler = handle_system_ctl, - }, { .method = NEU_HTTP_METHOD_GET, .type = NEU_HTTP_HANDLER_FUNCTION, diff --git a/plugins/restful/system_handle.c b/plugins/restful/system_handle.c deleted file mode 100644 index 388fd5401..000000000 --- a/plugins/restful/system_handle.c +++ /dev/null @@ -1,32 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "json/neu_json_fn.h" - -#include "handle.h" -#include "utils/http.h" -#include "utils/neu_jwt.h" - -#include "parser/neu_json_system.h" -#include "system_handle.h" - -void handle_system_ctl(nng_aio *aio) -{ - NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT( - aio, neu_json_system_ctl_req_t, neu_json_decode_system_ctl_req, { - if (req->action == 1) { - neu_http_ok(aio, "{\"error\": 0 }"); - exit(-2); - } - }) -} \ No newline at end of file diff --git a/plugins/restful/system_handle.h b/plugins/restful/system_handle.h deleted file mode 100644 index c453a138c..000000000 --- a/plugins/restful/system_handle.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * NEURON IIoT System for Industry 4.0 - * Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#ifndef _NEU_SYSTEM_HANDLE_H_ -#define _NEU_SYSTEM_HANDLE_H_ - -#include - -void handle_system_ctl(nng_aio *aio); - -#endif \ No newline at end of file diff --git a/src/parser/neu_json_system.c b/src/parser/neu_json_system.c deleted file mode 100644 index d9e7dbcb1..000000000 --- a/src/parser/neu_json_system.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * NEURON IIoT System for Industry 4.0 - * Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -/* - * DO NOT EDIT THIS FILE MANUALLY! - * It was automatically generated by `json-autotype`. - */ - -#include -#include - -#include "json/json.h" - -#include "neu_json_system.h" - -void neu_json_decode_system_ctl_req_free(neu_json_system_ctl_req_t *req) -{ - if (req != NULL) { - free(req); - } -} - -int neu_json_decode_system_ctl_req(char * buf, - neu_json_system_ctl_req_t **result) -{ - int ret = 0; - void *json_obj = neu_json_decode_new(buf); - - neu_json_system_ctl_req_t *req = - calloc(1, sizeof(neu_json_system_ctl_req_t)); - if (req == NULL) { - return -1; - } - - neu_json_elem_t req_elems[] = { - { - .name = "action", - .t = NEU_JSON_INT, - }, - }; - - ret = neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_elems), - req_elems); - if (ret != 0) { - free(req); - if (json_obj != NULL) { - neu_json_decode_free(json_obj); - } - return -1; - } - - req->action = req_elems[0].v.val_int; - *result = req; - - if (json_obj != NULL) { - neu_json_decode_free(json_obj); - } - return ret; -} \ No newline at end of file diff --git a/src/parser/neu_json_system.h b/src/parser/neu_json_system.h deleted file mode 100644 index 3299870ed..000000000 --- a/src/parser/neu_json_system.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * NEURON IIoT System for Industry 4.0 - * Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -/* - * DO NOT EDIT THIS FILE MANUALLY! - * It was automatically generated by `json-autotype`. - */ - -#ifndef _NEU_JSON_API_NEU_JSON_SYSTEM_H_ -#define _NEU_JSON_API_NEU_JSON_SYSTEM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int action; -} neu_json_system_ctl_req_t; - -void neu_json_decode_system_ctl_req_free(neu_json_system_ctl_req_t *req); -int neu_json_decode_system_ctl_req(char * buf, - neu_json_system_ctl_req_t **result); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tests/ut/json_test.cc b/tests/ut/json_test.cc index 989591b8a..1d640b92c 100644 --- a/tests/ut/json_test.cc +++ b/tests/ut/json_test.cc @@ -1,10 +1,7 @@ #include -#include "json/json.h" - #include "utils/log.h" - -#include "parser/neu_json_system.h" +#include "json/json.h" zlog_category_t *neuron = NULL; TEST(JsonTest, DecodeField) @@ -331,17 +328,6 @@ TEST(JsonTest, EncodeArray) neu_json_decode_free(ob); } -TEST(JsonTest, System_ctl) -{ - char * buf = (char *) "{\"action\": 1}"; - char * buf1 = (char *) "{\"action1\": 1}"; - neu_json_system_ctl_req_t *req = NULL; - EXPECT_EQ(-1, neu_json_decode_system_ctl_req(buf1, &req)); - EXPECT_EQ(0, neu_json_decode_system_ctl_req(buf, &req)); - EXPECT_EQ(1, req->action); - free(req); -} - int main(int argc, char **argv) { zlog_init("./config/dev.conf");