add: cache (WIP)

This commit is contained in:
Tobias Reisinger 2020-08-13 16:29:26 +02:00
parent f167f9caec
commit 6d37bd9734
26 changed files with 365 additions and 61 deletions

View file

@ -19,7 +19,7 @@ api_v1_controllers_GET(struct mg_connection *nc, struct http_message *hm, endpoi
for(int i = 0; all_controllers[i] != NULL; ++i)
{
cJSON *json_controller = controller_to_json(all_controllers[i]);
cJSON *json_controller = cJSON_CreateRaw(controller_to_json(all_controllers[i]));
cJSON_AddItemToArray(json, json_controller);
}

View file

@ -36,7 +36,7 @@ api_v1_controllers_STR_GET(struct mg_connection *nc, struct http_message *hm, en
return;
}
cJSON *json = controller_to_json(controller);
cJSON *json = cJSON_CreateRaw(controller_to_json(controller));
endpoint_response_json(response, 200, json);
cJSON_Delete(json);
@ -140,7 +140,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
}
cJSON_Delete(json);
json = controller_to_json(controller);
json = cJSON_CreateRaw(controller_to_json(controller));
command_set_controller_name(controller);

View file

@ -39,7 +39,7 @@ api_v1_controllers_STR_relays_GET(struct mg_connection *nc, struct http_message
for(int i = 0; all_relays[i] != NULL; ++i)
{
cJSON *json_relay = relay_to_json(all_relays[i]);
cJSON *json_relay = cJSON_CreateRaw(relay_to_json(all_relays[i]));
cJSON_AddItemToArray(json, json_relay);
}

View file

@ -47,7 +47,7 @@ api_v1_controllers_STR_relays_INT_GET(struct mg_connection *nc, struct http_mess
return;
}
cJSON *json = relay_to_json(relay);
cJSON *json = cJSON_CreateRaw(relay_to_json(relay));
endpoint_response_json(response, 200, json);
cJSON_Delete(json);
@ -220,7 +220,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
}
cJSON_Delete(json);
json = relay_to_json(relay);
json = cJSON_CreateRaw(relay_to_json(relay));
command_set_relay_schedule(relay);

View file

@ -20,7 +20,7 @@ api_v1_relays_GET(struct mg_connection *nc, struct http_message *hm, endpoint_ar
for(int i = 0; all_relays[i] != NULL; ++i)
{
cJSON *json_relay = relay_to_json(all_relays[i]);
cJSON *json_relay = cJSON_CreateRaw(relay_to_json(all_relays[i]));
cJSON_AddItemToArray(json, json_relay);
}

View file

@ -40,7 +40,7 @@ api_v1_relays_tag_STR_GET(struct mg_connection *nc, struct http_message *hm, end
{
continue;
}
cJSON *json_relay = relay_to_json(relay);
cJSON *json_relay = cJSON_CreateRaw(relay_to_json(relay));
cJSON_AddItemToArray(json, json_relay);

View file

@ -145,7 +145,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
}
cJSON_Delete(json);
json = schedule_to_json(new_schedule);
json = cJSON_CreateRaw(schedule_to_json(new_schedule));
endpoint_response_json(response, 201, json);
cJSON_Delete(json);
@ -165,7 +165,7 @@ api_v1_schedules_GET(struct mg_connection *nc, struct http_message *hm, endpoint
for(int i = 0; all_schedules[i] != NULL; ++i)
{
cJSON *json_schedule = schedule_to_json(all_schedules[i]);
cJSON *json_schedule = cJSON_CreateRaw(schedule_to_json(all_schedules[i]));
cJSON_AddItemToArray(json, json_schedule);
}

View file

@ -37,7 +37,7 @@ api_v1_schedules_STR_GET(struct mg_connection *nc, struct http_message *hm, endp
return;
}
cJSON *json = schedule_to_json(schedule);
cJSON *json = cJSON_CreateRaw(schedule_to_json(schedule));
endpoint_response_json(response, 200, json);
cJSON_Delete(json);
@ -176,7 +176,7 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
}
cJSON_Delete(json);
json = schedule_to_json(schedule);
json = cJSON_CreateRaw(schedule_to_json(schedule));
endpoint_response_json(response, 200, json);
cJSON_Delete(json);

View file

@ -40,7 +40,7 @@ api_v1_schedules_tag_STR_GET(struct mg_connection *nc, struct http_message *hm,
{
continue;
}
cJSON *json_schedule = schedule_to_json(schedule);
cJSON *json_schedule = cJSON_CreateRaw(schedule_to_json(schedule));
cJSON_AddItemToArray(json, json_schedule);

View file

@ -52,7 +52,7 @@ api_v1_tags_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_
{
continue;
}
cJSON *json_relay = relay_to_json(relay);
cJSON *json_relay = cJSON_CreateRaw(relay_to_json(relay));
cJSON_AddItemToArray(json_relays, json_relay);
@ -66,7 +66,7 @@ api_v1_tags_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_
{
continue;
}
cJSON *json_schedule = schedule_to_json(schedule);
cJSON *json_schedule = cJSON_CreateRaw(schedule_to_json(schedule));
cJSON_AddItemToArray(json_schedules, json_schedule);