diff --git a/plugins/restful/handle.c b/plugins/restful/handle.c index c4c6fe8b..913aacb4 100644 --- a/plugins/restful/handle.c +++ b/plugins/restful/handle.c @@ -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) diff --git a/plugins/restful/template_handle.c b/plugins/restful/template_handle.c index 6b25aedb..826192c5 100644 --- a/plugins/restful/template_handle.c +++ b/plugins/restful/template_handle.c @@ -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); + }); + } +} diff --git a/plugins/restful/template_handle.h b/plugins/restful/template_handle.h index 6f0b51d1..31ff9bf7 100644 --- a/plugins/restful/template_handle.h +++ b/plugins/restful/template_handle.h @@ -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);