core-legacy/controllers/api_v1_relays.cc
2019-08-07 00:14:57 +02:00

23 lines
584 B
C++

#include <netdb.h>
#include <models/relay_dbo.h>
#include <helpers.h>
#include "api_v1_relays.h"
using namespace api::v1;
void
relays::get_all(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{
relay_dbo **all_relays = relay_dbo::get_all();
Json::Value all_relays_json(Json::arrayValue);
for(int i = 0; all_relays[i] != nullptr; i++)
{
all_relays_json.append(all_relays[i]->to_json());
}
auto resp = HttpResponse::newHttpJsonResponse(all_relays_json);
callback(resp);
relay_dbo::free_list(all_relays);
}