2020-05-05 23:05:36 +00:00
|
|
|
#include <cJSON.h>
|
2020-05-20 23:33:18 +00:00
|
|
|
#include <macros.h>
|
2020-05-05 23:05:36 +00:00
|
|
|
#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
|
2020-05-20 23:33:18 +00:00
|
|
|
api_v1_controllers_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
2020-05-05 23:05:36 +00:00
|
|
|
{
|
|
|
|
(void)args;
|
|
|
|
(void)hm;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-05-30 22:23:57 +00:00
|
|
|
endpoint_response_json(response, 200, json);
|
2020-05-05 23:05:36 +00:00
|
|
|
cJSON_Delete(json);
|
|
|
|
controller_free_list(all_controllers);
|
|
|
|
}
|