aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael McVady <femtonaut@gmail.com>2023-01-02 11:19:46 -0600
committerMichael McVady <femtonaut@gmail.com>2023-01-02 11:19:46 -0600
commitad5f6b20264ca4abc19bc470bff070b75eaf61f9 (patch)
tree806f9704c49822a0483284b5d2918f72540f6b19
parent9c25735888a47dbba8ee536836b5c0a3dd75f627 (diff)
Fix JSON HTTP 404
-rw-r--r--src/clog.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/clog.c b/src/clog.c
index 3ef2121..83f9f79 100644
--- a/src/clog.c
+++ b/src/clog.c
@@ -320,6 +320,7 @@ render_posts_json(struct post_request *post_req)
") row;"
);
}
+
if (err == KORE_RESULT_ERROR)
{
post_req->resp_status = HTTP_STATUS_INTERNAL_ERROR;
@@ -327,24 +328,14 @@ render_posts_json(struct post_request *post_req)
goto out;
}
- rows = kore_pgsql_ntuples(&sql);
- kore_log(LOG_DEBUG, "JSON rows: %d", rows);
-
- int fields = kore_pgsql_nfields(&sql);
- kore_log(LOG_DEBUG, "JSON fields: %d", fields);
-
- int len = kore_pgsql_getlength(&sql, 0, 0);
- kore_log(LOG_DEBUG, "JSON fields: %d", fields);
-
- kore_pgsql_logerror(&sql);
+ if (kore_pgsql_getlength(&sql, 0, 0) == 0)
+ {
+ post_req->resp_status = HTTP_STATUS_NOT_FOUND;
+ goto out;
+ }
if (rows == 1) {
json = kore_pgsql_getvalue(&sql, 0, 0);
- kore_log(LOG_DEBUG, "JSON data: %s", json);
-
- len = kore_pgsql_getlength(&sql, 0, 0);
- kore_log(LOG_DEBUG, "JSON data len: %d", len);
-
kore_buf_append(
post_req->resp_buf,
json,