diff --git a/README.md b/README.md index adbdb6f..c3010e6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ - ~~Пройтись по коду и максимально наставить const~~ - Указать возможные исключения в интерфейсах DAO - Вынести User в структуру. Hashed Password структура должна изначально состоять в другой структуре -- SharedPtr - передавать по константной ссылке. +- ~~SharedPtr - передавать по константной ссылке.~~ - Сделать интеграционный тест по ручкам # UseCase'ы приложения: diff --git a/src/endpoints_handlers/AuthLoginExecutor.h b/src/endpoints_handlers/AuthLoginExecutor.h index f6b4a51..bf66fb1 100644 --- a/src/endpoints_handlers/AuthLoginExecutor.h +++ b/src/endpoints_handlers/AuthLoginExecutor.h @@ -17,13 +17,13 @@ template class AuthLoginExecutor : public IExecutor { mysqlx::Session& session_; - std::shared_ptr user_dao_; - std::shared_ptr auth_dao_; + const std::shared_ptr& user_dao_; + const std::shared_ptr& auth_dao_; public: AuthLoginExecutor(mysqlx::Session& session, - std::shared_ptr user_dao, - std::shared_ptr auth_dao) + const std::shared_ptr& user_dao, + const std::shared_ptr& auth_dao) : session_(session), user_dao_(user_dao), auth_dao_(auth_dao) { } diff --git a/src/endpoints_handlers/AuthRegistrationExecutor.h b/src/endpoints_handlers/AuthRegistrationExecutor.h index aee194d..2532b6b 100644 --- a/src/endpoints_handlers/AuthRegistrationExecutor.h +++ b/src/endpoints_handlers/AuthRegistrationExecutor.h @@ -15,11 +15,11 @@ template class AuthRegistrationExecutor : public IExecutor { mysqlx::Session& session_; - std::shared_ptr user_dao_; + const std::shared_ptr& user_dao_; public: AuthRegistrationExecutor(mysqlx::Session& session, - std::shared_ptr user_dao) + const std::shared_ptr& user_dao) : session_(session), user_dao_(user_dao) { } diff --git a/src/endpoints_handlers/HandleRequest.h b/src/endpoints_handlers/HandleRequest.h index 860faf6..3f3b008 100644 --- a/src/endpoints_handlers/HandleRequest.h +++ b/src/endpoints_handlers/HandleRequest.h @@ -17,10 +17,13 @@ void HandleRequest( boost::beast::http::request>&& req, Send&& send) { + static std::shared_ptr user_dao = std::make_shared(GetMySqlSession()); + static std::shared_ptr auth_dao = std::make_shared(GetMySqlSession()); + static RootExecutor root_executor( GetMySqlSession(), - std::make_shared(GetMySqlSession()), - std::make_shared(GetMySqlSession()) + user_dao, + auth_dao ); root_executor(doc_root, std::move(req), std::forward(send)); diff --git a/src/endpoints_handlers/RootExecutor.h b/src/endpoints_handlers/RootExecutor.h index 03714ae..9adecc8 100644 --- a/src/endpoints_handlers/RootExecutor.h +++ b/src/endpoints_handlers/RootExecutor.h @@ -28,14 +28,14 @@ class RootExecutor private: RoutesPathes routes_pathes_; mysqlx::Session& session_; - std::shared_ptr user_dao_; - std::shared_ptr auth_dao_; + const std::shared_ptr& user_dao_; + const std::shared_ptr& auth_dao_; public: RootExecutor( mysqlx::Session& session, - std::shared_ptr user_dao, - std::shared_ptr auth_dao) : + const std::shared_ptr& user_dao, + const std::shared_ptr& auth_dao) : session_(session), user_dao_(user_dao), auth_dao_(auth_dao) { routes_pathes_["/api/v1/Auth/Register"] = std::make_unique(