diff --git a/include/cserver/clients/http/component.hpp b/include/cserver/clients/http/component.hpp index 40b3d7f..32b7195 100644 --- a/include/cserver/clients/http/component.hpp +++ b/include/cserver/clients/http/component.hpp @@ -59,12 +59,8 @@ private: }; template inline auto ReadHeaders(Socket&& socket, auto&&...) const -> cserver::Task { - boost::system::error_code ec; std::string serverResponse; - co_await boost::asio::async_read_until(socket, boost::asio::dynamic_buffer(serverResponse), "\r\n\r\n", boost::asio::redirect_error(boost::asio::use_awaitable, ec)); - if(ec) { - throw BoostErrorWrapper{ec}; - }; + co_await boost::asio::async_read_until(socket, boost::asio::dynamic_buffer(serverResponse), "\r\n\r\n", boost::asio::use_awaitable); server::http::HTTPResponse response; std::istringstream responseStream(std::move(serverResponse)); std::string httpVersion; @@ -80,11 +76,7 @@ private: inline auto ReadBody(Socket&& socket, std::size_t length, auto&&...) const -> cserver::Task { std::string response; response.reserve(length); - boost::system::error_code ec; - co_await boost::asio::async_read(socket, boost::asio::dynamic_buffer(response), boost::asio::transfer_at_least(length), boost::asio::redirect_error(boost::asio::use_awaitable, ec)); - if(ec) { - throw BoostErrorWrapper{ec}; - }; + co_await boost::asio::async_read(socket, boost::asio::dynamic_buffer(response), boost::asio::transfer_at_least(length), boost::asio::use_awaitable); co_return response; }; template @@ -96,7 +88,7 @@ private: break; }; if(ec) { - throw BoostErrorWrapper{ec}; + throw boost::system::error_code{ec}; }; }; co_return response; diff --git a/include/cserver/clients/http/response.hpp b/include/cserver/clients/http/response.hpp index da9f324..fecefec 100644 --- a/include/cserver/clients/http/response.hpp +++ b/include/cserver/clients/http/response.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include namespace cserver::clients::http { @@ -19,9 +18,8 @@ public: co_return false; }; if(ec) { - throw BoostErrorWrapper{ec}; + throw boost::system::error_code(ec); }; - this->body.resize(n); co_return true; }; diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index 30742c6..26a4a51 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -208,7 +208,7 @@ public: return utempl::Tuple{}; } else { if constexpr(requires{GetDependencies();}) { - return GetDependencies{}>{}))::Type>(); + return GetDependencies{}>{})>(); } else { return utempl::Tuple{names..., Magic(loopholes::Getter{}>{})}; }; diff --git a/include/cserver/server/server/server.hpp b/include/cserver/server/server/server.hpp index f864ca5..cb59df2 100644 --- a/include/cserver/server/server/server.hpp +++ b/include/cserver/server/server/server.hpp @@ -33,15 +33,18 @@ struct Server { return {}; }); }; - template - inline constexpr Server(utempl::Wrapper, T& context) : + template < + utempl::ConstexprString name, + typename T, + std::size_t... Is> + inline constexpr Server(std::index_sequence, utempl::Wrapper, T& context) : taskProcessor(context.template FindComponent()), - handlers{ - [&](std::index_sequence) -> utempl::Tuple&...> { - return {context.template FindComponent(kNames)>()...}; - }(std::index_sequence_for()) - }, + handlers{context.template FindComponent(kNames)>()...}, port(T::kConfig.template Get().template Get<"port">()) { + + }; + inline constexpr Server(auto name, auto& context) : + Server(std::index_sequence_for{}, name, context) { }; template auto ProcessHandler(Socket&& socket, http::HTTPRequest request) -> Task {