#include <cJSON.h> #include <macros.h> #include <constants.h> #include <endpoints/api_v1_controllers.h> #include <logger.h> #include <models/junction_tag.h> #include <models/controller.h> #include <models/tag.h> void api_v1_controllers_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response) { (void)args; (void)hm; (void)nc; controller_t** all_controllers = controller_get_all(); cJSON *json = cJSON_CreateArray(); LOGGER_DEBUG("filling json array\n"); for(int i = 0; all_controllers[i] != NULL; ++i) { cJSON *json_controller = controller_to_json(all_controllers[i]); cJSON_AddItemToArray(json, json_controller); } endpoint_response_json(response, 200, json); cJSON_Delete(json); controller_free_list(all_controllers); }