generated from Sithas/conan_template
Постановка нового маршрута
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "AuthRegistrationExecutor.h"
|
||||
#include "AuthLoginExecutor.h"
|
||||
#include "AuthLogoutExecutor.h"
|
||||
#include "UserGetMedicationsExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../DAO/IAuthDAO.h"
|
||||
#include "./../helpers/helpers.h"
|
||||
@@ -24,6 +25,8 @@ class RootExecutor
|
||||
Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteAuthLogoutExecutor = AuthLogoutExecutor<
|
||||
Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteUserGetMedicationsExecutor = UserGetMedicationsExecutor<
|
||||
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>>;
|
||||
@@ -46,26 +49,41 @@ public:
|
||||
session_(session), user_dao_(user_dao), auth_dao_(auth_dao)
|
||||
{
|
||||
routes_pathes_["/api/v1/Auth/Register"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post, std::make_shared<RouteAuthRegistrationExecutor>(
|
||||
session_,
|
||||
user_dao_
|
||||
)}
|
||||
}
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{
|
||||
boost::beast::http::verb::post, std::make_shared<RouteAuthRegistrationExecutor>(
|
||||
session_,
|
||||
user_dao_
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
routes_pathes_["/api/v1/Auth/Login"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLoginExecutor>(session_, user_dao_, auth_dao_)}
|
||||
}
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{
|
||||
boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLoginExecutor>(session_, user_dao_, auth_dao_)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
routes_pathes_["/api/v1/Auth/Logout"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLogoutExecutor>(session_, auth_dao_)}
|
||||
}
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{
|
||||
boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLogoutExecutor>(session_, auth_dao_)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
routes_pathes_["api/v1/User/Medications"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{
|
||||
boost::beast::http::verb::get,
|
||||
std::make_shared<RouteUserGetMedicationsExecutor>()
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,7 +91,7 @@ public:
|
||||
boost::beast::string_view doc_root,
|
||||
Request&& req,
|
||||
Send&& send
|
||||
)
|
||||
)
|
||||
{
|
||||
const std::string& route = req.target();
|
||||
const bool is_match_route = routes_pathes_.count(route);
|
||||
@@ -163,7 +181,7 @@ private:
|
||||
StringResponse SendBadRequest(
|
||||
Request&& req,
|
||||
boost::beast::string_view why
|
||||
)
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::bad_request, req.version()
|
||||
@@ -179,7 +197,7 @@ private:
|
||||
StringResponse SendNotFound(
|
||||
Request&& req,
|
||||
boost::beast::string_view target
|
||||
)
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::not_found, req.version()
|
||||
@@ -195,7 +213,7 @@ private:
|
||||
StringResponse SendServerError(
|
||||
Request&& req,
|
||||
boost::beast::string_view what
|
||||
)
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::internal_server_error, req.version()
|
||||
|
||||
Reference in New Issue
Block a user