mirror of
https://github.com/emqx/neuron.git
synced 2026-10-16 20:30:39 +08:00
rm system api
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <jwt.h>
|
||||
#include <libgen.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -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 <nng/nng.h>
|
||||
|
||||
void handle_system_ctl(nng_aio *aio);
|
||||
|
||||
#endif
|
||||
@@ -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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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
|
||||
+1
-15
@@ -1,10 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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");
|
||||
|
||||
Reference in New Issue
Block a user