POST support WIP
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-01-21 23:00:59 +01:00
parent 9acd116ab2
commit f1a4c5448b
8 changed files with 113 additions and 100 deletions

View File

@@ -42,7 +42,7 @@
int outlet_create_handler(short event, restd_conn_t *conn, void *userdata)
{
printf("outlet_create_handler\n\n");
if (event & RESTD_EVENT_CLOSE)
if (event & RESTD_EVENT_WRITE)
{
off_t data_size;
@@ -55,6 +55,9 @@ int outlet_create_handler(short event, restd_conn_t *conn, void *userdata)
data = restd_http_get_content(conn, 0, &data_size);
printf("2/data size: %ld\n", data_size);
printf("3/data size: %s\n", data);
#if 0
root_node = json_tokener_parse(data);
free(data);
@@ -71,6 +74,10 @@ int outlet_create_handler(short event, restd_conn_t *conn, void *userdata)
return RESTD_CLOSE;
}
}
#endif
restd_http_response(conn, 204, "application/json", "{}", 2);
return RESTD_CLOSE;
}
restd_http_response(conn, 400, "application/json", "{\"status\":\"error\"}", 18);

View File

@@ -62,8 +62,8 @@ int setup_rest_server(restd_server_t *rest_server, const char *port, const char
//restd_server_register_request_handler(rest_server, restd_rest_handler);
restd_server_register_error_handler(rest_server, my_error_handler);
restd_server_register_hook(rest_server, restd_rest_handler, NULL);
restd_server_register_call_hooks_handler(rest_server, restd_rest_handler);
// restd_server_register_hook(rest_server, restd_http_handler, NULL);
// Capabilities.
restd_server_register_hook_on_path(rest_server, "GET", "/api/v1/capabilities", NULL, dm);