diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clog.c | 29 |
1 files changed, 7 insertions, 22 deletions
@@ -40,7 +40,8 @@ static const char *accept_json = "application/json"; static const char *database = "db"; static const char * const error_msg[] = { - [201] = "OK DOKEY", + [HTTP_STATUS_OK] = "OK", // 200 + [HTTP_STATUS_CREATED] = "Resource created successfully.", // 201 [HTTP_STATUS_BAD_REQUEST] = "There was an error processing the request data.", // 403? [HTTP_STATUS_NOT_FOUND] = "Resource not found.", // 404 [HTTP_STATUS_INTERNAL_ERROR] = "There was an error processing the request.", // 500 @@ -150,7 +151,8 @@ get_content_type(struct http_request *req) { return HTML; } -int http_ok_resp( +int +http_ok_resp( struct http_request *req, enum content_type type, enum http_status_code status, @@ -189,7 +191,8 @@ int http_ok_resp( return KORE_RESULT_OK; } -int http_err_resp( +int +http_err_resp( struct http_request *req, enum content_type type, enum http_status_code status @@ -296,8 +299,6 @@ post_posts(struct http_request *req) { const char *title = NULL; const char *body = NULL; - struct post_query pq; - struct kore_json_item *item = NULL; struct kore_json json; @@ -356,23 +357,7 @@ post_posts(struct http_request *req) { out: ; - // XXX Not sure about this hack to return the created resource. - if (status == HTTP_STATUS_CREATED) { - - post_query_init(&pq, type, id); - - (void) sql_select_posts(&pq); - if (pq.status == QUERY_STATUS_NOT_FOUND) - http_err_resp(req, pq.type, HTTP_STATUS_NOT_FOUND); - else if (pq.status == QUERY_STATUS_ERROR) - http_err_resp(req, pq.type, HTTP_STATUS_INTERNAL_ERROR); - else - http_ok_resp(req, pq.type, HTTP_STATUS_OK, pq.result); - - post_query_cleanup(&pq); - } - else - http_err_resp(req, type, status); + http_err_resp(req, type, status); kore_json_cleanup(&json); |