3#include "util/Taggable.hpp"
4#include "web/ng/Error.hpp"
5#include "web/ng/Request.hpp"
6#include "web/ng/Response.hpp"
8#include <boost/asio/spawn.hpp>
9#include <boost/beast/core/flat_buffer.hpp>
28 std::optional<bool> isAdmin_;
63 ip_ = std::move(newIp);
81 template <std::invocable T>
85 if (not isAdmin_.has_value())
95 boost::beast::flat_buffer buffer_;
104 std::chrono::seconds{11};
115 boost::beast::flat_buffer buffer,
126 setTimeout(std::chrono::steady_clock::duration newTimeout) = 0;
135 virtual std::expected<void, Error>
144 virtual std::expected<Request, Error>
145 receive(boost::asio::yield_context yield) = 0;
153 close(boost::asio::yield_context yield) = 0;
159using ConnectionPtr = std::unique_ptr<Connection>;
A factory for TagDecorator instantiation.
Definition Taggable.hpp:165
A base class that allows attaching a tag decorator to a subclass.
Definition Taggable.hpp:236
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:32
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:103
Represents an HTTP or Websocket response.
Definition Response.hpp:21