diff options
author | Michael McVady <femtonaut@gmail.com> | 2024-01-04 20:15:23 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2024-01-04 20:15:23 -0600 |
commit | b566d12f8df18155e610337246a06bded2e65ab5 (patch) | |
tree | 680bcc5d85fb10e74ba86e824f0d5c046a131fad /src/clog.c | |
parent | f285a28969b10000283c6e2f401479f05cf3fd75 (diff) |
Delete JSON API
Diffstat (limited to 'src/clog.c')
-rw-r--r-- | src/clog.c | 69 |
1 files changed, 0 insertions, 69 deletions
@@ -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; |