Базовая компиляция контроллеров и executor'ов

This commit is contained in:
Антон
2025-08-25 19:47:16 +03:00
parent 39b1625fb5
commit 83a99bbad7
3 changed files with 51 additions and 20 deletions
+46
View File
@@ -0,0 +1,46 @@
#include "IExecutor.h"
#include "IController.h"
#include "Controller.h"
#include "AuthRegistrationExecutor.h"
namespace uad
{
template <class Body, class Allocator, class ResponseType>
class RootExecutor : public IExecutor<Body, Allocator, ResponseType>
{
using IRouteExecutor = IExecutor<Body, Allocator, boost::beast::http::string_body>;
using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<
Body, Allocator, boost::beast::http::string_body>;
using IRouteController = IController<Body, Allocator, boost::beast::http::string_body>;
using RouteController = Controller<Body, Allocator, boost::beast::http::string_body>;
using RoutesPathes = std::unordered_map<std::string, std::unique_ptr<IRouteController>>;
private:
RoutesPathes routes_pathes_;
public:
RootExecutor()
{
typename RouteController::HTTPMethodsToExecutors authorization_registration_executors {
{boost::beast::http::verb::post, std::make_shared<RouteAuthRegistrationExecutor>()}
};
routes_pathes_["/api/v1/Auth/Register"] = std::make_unique<RouteController>(
std::move(authorization_registration_executors)
);
}
boost::beast::http::response<ResponseType> operator ()(
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
) override
{
boost::beast::http::response<ResponseType> res{
boost::beast::http::status::ok, req.version()
};
res.body() = "{ \"detail\": \"ok\"}";
res.set(boost::beast::http::field::content_type, "application/json");
res.content_length(res.body().size());
return res;
}
};
}