22#include "util/Taggable.hpp"
23#include "web/ng/Error.hpp"
24#include "web/ng/Request.hpp"
25#include "web/ng/Response.hpp"
27#include <boost/asio/spawn.hpp>
28#include <boost/beast/core/flat_buffer.hpp>
47 std::optional<bool> isAdmin_;
82 ip_ = std::move(newIp);
100 template <std::invocable T>
104 if (not isAdmin_.has_value())
114 boost::beast::flat_buffer buffer_;
123 std::chrono::seconds{11};
134 boost::beast::flat_buffer buffer,
145 setTimeout(std::chrono::steady_clock::duration newTimeout) = 0;
154 virtual std::expected<void, Error>
163 virtual std::expected<Request, Error>
164 receive(boost::asio::yield_context yield) = 0;
172 close(boost::asio::yield_context yield) = 0;
178using ConnectionPtr = std::unique_ptr<Connection>;
A factory for TagDecorator instantiation.
Definition Taggable.hpp:184
A base class that allows attaching a tag decorator to a subclass.
Definition Taggable.hpp:255
virtual std::expected< Request, Error > receive(boost::asio::yield_context yield)=0
Receive a request from the client.
virtual std::expected< void, Error > send(Response response, boost::asio::yield_context yield)=0
Send a response to the client.
Connection(std::string ip, boost::beast::flat_buffer buffer, util::TagDecoratorFactory const &tagDecoratorFactory)
Construct a new Connection object.
Definition Connection.cpp:51
virtual void close(boost::asio::yield_context yield)=0
Gracefully close the connection.
virtual void setTimeout(std::chrono::steady_clock::duration newTimeout)=0
Get the timeout for send, receive, and close operations. For WebSocket connections,...
static constexpr std::chrono::steady_clock::duration kDEFAULT_TIMEOUT
The default timeout for send, receive, and close operations.
Definition Connection.hpp:122
Represents an HTTP or Websocket response.
Definition Response.hpp:40