#include #include #include #include #include #include #include #include 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(); 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); }