add: more debugging

add: more options for testing
This commit is contained in:
Tobias Reisinger 2020-08-14 23:18:22 +02:00
parent 0efbd2a22f
commit e84d54f562
23 changed files with 130 additions and 63 deletions

View file

@ -35,8 +35,9 @@ api_v1_controllers_STR_GET(struct mg_connection *nc, struct http_message *hm, en
endpoint_response_text(response, 404, content, STRLEN(content));
return;
}
LOGGER_DEBUG("returning controller for uid '%s'\n", args[0].value.v_str);
cJSON *json = cJSON_CreateRaw(controller_to_json(controller));
cJSON *json = controller_to_json(controller);
endpoint_response_json(response, 200, json);
cJSON_Delete(json);
@ -69,6 +70,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
endpoint_response_text(response, 404, content, STRLEN(content));
return;
}
LOGGER_DEBUG("starting overwrite for controller %s\n", args[0].value.v_str);
cJSON *json = cJSON_ParseWithLength(hm->body.p, hm->body.len);
@ -87,6 +89,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
{
strncpy(controller->name, json_name->valuestring, MAX_NAME_LENGTH);
controller->name[MAX_NAME_LENGTH] = '\0';
LOGGER_DEBUG("new controller name: %s\n", controller->name);
}
else
{
@ -108,6 +111,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
{
strncpy(controller->ip, json_ip->valuestring, IP_LENGTH);
controller->ip[IP_LENGTH] = '\0';
LOGGER_DEBUG("new controller ip: %s\n", controller->ip);
}
else
{
@ -138,9 +142,10 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
endpoint_response_text(response, 500, content, STRLEN(content));
return;
}
LOGGER_DEBUG("saved controller %s\n", args[0].value.v_str);
cJSON_Delete(json);
json = cJSON_CreateRaw(controller_to_json(controller));
json = controller_to_json(controller);
command_set_controller_name(controller);
@ -187,6 +192,7 @@ api_v1_controllers_STR_DELETE(struct mg_connection *nc, struct http_message *hm,
}
else
{
LOGGER_DEBUG("deleted controller %s\n", args[0].value.v_str);
endpoint_response_text(response, 200, "", 0);
}
controller_free(controller);