REFACTOR
This commit is contained in:
parent
0460b2e9f7
commit
176483d72f
59 changed files with 11 additions and 45 deletions
endpoints
|
@ -1,31 +0,0 @@
|
|||
#include <cJSON.h>
|
||||
#include <macros.h>
|
||||
#include <constants.h>
|
||||
#include <endpoints/api_v1_relays.h>
|
||||
#include <logger.h>
|
||||
#include <models/junction_tag.h>
|
||||
#include <models/relay.h>
|
||||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_relays_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)args;
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
relay_t** all_relays = relay_get_all();
|
||||
|
||||
cJSON *json = cJSON_CreateArray();
|
||||
|
||||
for(int i = 0; all_relays[i] != NULL; ++i)
|
||||
{
|
||||
cJSON *json_relay = relay_to_json(all_relays[i]);
|
||||
|
||||
cJSON_AddItemToArray(json, json_relay);
|
||||
}
|
||||
|
||||
endpoint_response_json(response, 200, json);
|
||||
cJSON_Delete(json);
|
||||
relay_free_list(all_relays);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue