Завершение контроллера

This commit is contained in:
Антон
2025-08-24 08:25:41 +03:00
parent d53814c3cc
commit 029f9c2fd3
3 changed files with 24 additions and 15 deletions
+9 -5
View File
@@ -9,19 +9,23 @@ namespace uad
template <class Body, class Allocator, class ResponseType>
class Controller : IController<Body, Allocator, ResponseType>
{
using HTTPMethodsToExecutors = std::unordered_map<boost::beast::http::verb, std::unique_ptr<IExecutor<Body, Allocator, ResponseType>>>;
public:
using HTTPMethodsToExecutors = std::unordered_map<boost::beast::http::verb, std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>>;
private:
HTTPMethodsToExecutors executors_;
public:
Controller() = default;
explicit Controller(HTTPMethodsToExecutors&& executors) {}
explicit Controller(HTTPMethodsToExecutors&& executors): executors_(std::move(executors)) {}
std::optional<std::unique_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
std::optional<std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
boost::beast::http::verb method
) const override
) override
{
return std::nullopt;
if (!executors_.count(method)) return std::nullopt;
return std::make_optional(executors_.at(method));
}
};
}
+2 -2
View File
@@ -18,9 +18,9 @@ template <class Body, class Allocator, class ResponseType>
class IController
{
public:
virtual std::optional<std::unique_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
virtual std::optional<std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
boost::beast::http::verb method
) const = 0;
) = 0;
virtual ~IController() = default;
};
}