mirror of
https://github.com/emqx/neuron.git
synced 2026-10-22 01:05:56 +08:00
feat(restful): add node update api
This commit is contained in:
@@ -62,6 +62,30 @@ void handle_add_adapter(nng_aio *aio)
|
||||
})
|
||||
}
|
||||
|
||||
void handle_update_adapter(nng_aio *aio)
|
||||
{
|
||||
neu_plugin_t *plugin = neu_rest_get_plugin();
|
||||
|
||||
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
|
||||
aio, neu_json_update_node_req_t, neu_json_decode_update_node_req, {
|
||||
int ret = 0;
|
||||
neu_reqresp_head_t header = { 0 };
|
||||
neu_req_update_node_t cmd = { 0 };
|
||||
|
||||
header.ctx = aio;
|
||||
header.type = NEU_REQ_UPDATE_NODE;
|
||||
strcpy(cmd.node, req->name);
|
||||
strcpy(cmd.new_name, req->new_name);
|
||||
|
||||
ret = neu_plugin_op(plugin, header, &cmd);
|
||||
if (ret != 0) {
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
|
||||
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
void handle_del_adapter(nng_aio *aio)
|
||||
{
|
||||
neu_plugin_t *plugin = neu_rest_get_plugin();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "adapter.h"
|
||||
|
||||
void handle_add_adapter(nng_aio *aio);
|
||||
void handle_update_adapter(nng_aio *aio);
|
||||
void handle_del_adapter(nng_aio *aio);
|
||||
void handle_get_adapter(nng_aio *aio);
|
||||
void handle_get_adapter_resp(nng_aio *aio, neu_resp_get_node_t *nodes);
|
||||
|
||||
@@ -216,6 +216,12 @@ static struct neu_http_handler rest_handlers[] = {
|
||||
.url = "/api/v2/node",
|
||||
.value.handler = handle_add_adapter,
|
||||
},
|
||||
{
|
||||
.method = NEU_HTTP_METHOD_PUT,
|
||||
.type = NEU_HTTP_HANDLER_FUNCTION,
|
||||
.url = "/api/v2/node",
|
||||
.value.handler = handle_update_adapter,
|
||||
},
|
||||
{
|
||||
.method = NEU_HTTP_METHOD_DELETE,
|
||||
.type = NEU_HTTP_HANDLER_FUNCTION,
|
||||
|
||||
Reference in New Issue
Block a user