core-legacy/controllers/api_v1_controllers.h
Tobias Reisinger 8679bfe680 add: CORS and OPTIONS
add: 'off' schedule in db init
add: copy db to build dir
2019-09-08 23:24:31 +02:00

31 lines
2.2 KiB
C++

#pragma once
#include <drogon/HttpController.h>
using namespace drogon;
namespace api::v1
{
class controllers:public drogon::HttpController<controllers>
{
public:
METHOD_LIST_BEGIN
METHOD_ADD(controllers::post_discover, "/discover", Post, Options);
METHOD_ADD(controllers::get_all, "/", Get, Options);
METHOD_ADD(controllers::get_one_by_id, "/{1}", Get, Options);
METHOD_ADD(controllers::delete_one_by_id, "/{1}", Delete, Options);
METHOD_ADD(controllers::put_one_by_id, "/{1}", Put, Options, "filters::json_required", "filters::controllers::valid_json");
METHOD_ADD(controllers::get_relays_all, "/{1}/relays/", Get, Options);
METHOD_ADD(controllers::get_relays_one_by_id_and_num, "/{1}/relays/{2}", Get, Options);
METHOD_ADD(controllers::put_relays_one_by_id_and_num, "/{1}/relays/{2}", Put, Options, "filters::json_required", "filters::relays::valid_json");
METHOD_LIST_END
static void post_discover(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
static void get_all(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
static void get_one_by_id(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id);
static void delete_one_by_id(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id);
static void put_one_by_id(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id);
static void get_relays_all(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id);
static void get_relays_one_by_id_and_num(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id, int relay_num);
static void put_relays_one_by_id_and_num(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& controller_id, int relay_num);
};
}