From b566d12f8df18155e610337246a06bded2e65ab5 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Thu, 4 Jan 2024 20:15:23 -0600 Subject: Delete JSON API --- src/clog.c | 69 -------------------------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/src/clog.c b/src/clog.c index bd36b30..614ccb5 100644 --- a/src/clog.c +++ b/src/clog.c @@ -226,75 +226,6 @@ out: ; return KORE_RESULT_OK; } -int post_entry(struct http_request *req) { - int err = 0; - - int status = HTTP_STATUS_CREATED; - - const char *id = NULL; - const char *title = NULL; - const char *body = NULL; - - struct kore_json_item *item = NULL; - struct kore_json json; - - kore_json_init(&json, req->http_body->data, req->http_body->length); - - if (!kore_json_parse(&json)) { - status = HTTP_STATUS_BAD_REQUEST; - kore_log(LOG_ERR, "error parsing json: %s\n", kore_json_strerror()); - goto out; - } - - item = kore_json_find_string(json.root, "id"); - if (item != NULL) { - id = item->data.string; - kore_log(LOG_INFO, "id = '%s'\n", id); - // Check for valid resource ID/UUID - err = validate_uuid(id); - if (err == KORE_RESULT_ERROR) { - status = HTTP_STATUS_BAD_REQUEST; - kore_log(LOG_ERR, "Invalid entry UUID %s.", id); - goto out; - } - } - - item = kore_json_find_string(json.root, "title"); - if (item != NULL) { - title = item->data.string; - kore_log(LOG_INFO, "title = '%s'\n", title); - } else { - status = HTTP_STATUS_BAD_REQUEST; - kore_log(LOG_ERR, "error parsing title: %s\n", kore_json_strerror()); - goto out; - } - - item = kore_json_find_string(json.root, "body"); - if (item != NULL) { - body = item->data.string; - kore_log(LOG_INFO, "body = '%s'\n", body); - } else { - status = HTTP_STATUS_BAD_REQUEST; - kore_log(LOG_ERR, "error parsing body: %s\n", kore_json_strerror()); - goto out; - } - - err = sql_insert_entry(id, title, body); - - if (err == KORE_RESULT_ERROR) { - status = HTTP_STATUS_INTERNAL_ERROR; - goto out; - } - -out: ; - - http_err_resp(req, status); - - kore_json_cleanup(&json); - - return KORE_RESULT_OK; -} - int sql_select_entries(struct entry_query *eq) { int err = KORE_RESULT_OK; -- cgit v1.2.3