generated from Sithas/conan_template
Базовая компиляция контроллеров и executor'ов
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user