feat(restful): add template group get api

This commit is contained in:
eeff
2023-05-04 16:17:32 +08:00
parent b94b02d06e
commit a7db246201
3 changed files with 35 additions and 0 deletions
+6
View File
@@ -414,6 +414,12 @@ static struct neu_http_handler rest_handlers[] = {
.url = "/api/v2/template/group",
.value.handler = handle_del_template_group,
},
{
.method = NEU_HTTP_METHOD_GET,
.type = NEU_HTTP_HANDLER_FUNCTION,
.url = "/api/v2/template/group",
.value.handler = handle_get_template_group,
},
};
void neu_rest_handler(const struct neu_http_handler **handlers, uint32_t *size)
+28
View File
@@ -573,3 +573,31 @@ void handle_instantiate_template(nng_aio *aio)
}
})
}
void handle_get_template_group(nng_aio *aio)
{
neu_plugin_t *plugin = neu_rest_get_plugin();
NEU_VALIDATE_JWT(aio);
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_GET_TEMPLATE_GROUP,
};
neu_req_get_template_group_t cmd = { 0 };
int ret = neu_http_get_param_str(aio, "name", cmd.tmpl, sizeof(cmd.tmpl));
if (ret <= 0 || (size_t) ret >= sizeof(cmd.tmpl)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, NEU_ERR_PARAM_IS_WRONG, result_error);
});
return;
}
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);
});
}
}
+1
View File
@@ -33,6 +33,7 @@ void handle_get_templates_resp(nng_aio *aio, neu_resp_get_templates_t *resp);
void handle_add_template_group(nng_aio *aio);
void handle_update_template_group(nng_aio *aio);
void handle_del_template_group(nng_aio *aio);
void handle_get_template_group(nng_aio *aio);
void handle_add_template_tags(nng_aio *aio);
void handle_update_template_tags(nng_aio *aio);