|
Clio
develop
The XRP Ledger API server.
|
Web server class. More...
#include <Server.hpp>


Classes | |
| struct | Hooks |
| A struct that holds all the hooks for the server. More... | |
Public Types | |
| using | OnConnectCheck = std::function<std::expected<void, Response>(Connection const&)> |
| Check to perform for each new client connection. The check takes client ip as input and returns a Response if the check failed. Response will be sent to the client and the connection will be closed. | |
| using | OnIpChangeHook = impl::ConnectionHandler::OnIpChangeHook |
| Hook called when a connection's client ip changes (e.g. resolved from a proxy). | |
| using | OnDisconnectHook = impl::ConnectionHandler::OnDisconnectHook |
| Hook called when any connection disconnects. | |
Public Member Functions | |
| Server (boost::asio::io_context &ctx, boost::asio::ip::tcp::endpoint endpoint, std::optional< boost::asio::ssl::context > sslContext, ProcessingPolicy processingPolicy, std::optional< size_t > parallelRequestLimit, util::TagDecoratorFactory tagDecoratorFactory, ProxyIpResolver proxyIpResolver, size_t maxSubscriptionSendQueueSize, Hooks hooks) | |
| Construct a new Server object. | |
| Server (Server const &)=delete | |
| Copy constructor is deleted. The Server couldn't be copied. | |
| Server (Server &&)=delete | |
| Move constructor is deleted because connectionHandler_ contains references to some fields of the Server. | |
| void | onGet (std::string const &target, MessageHandler handler) |
| Set handler for GET requests. | |
| void | onPost (std::string const &target, MessageHandler handler) |
| Set handler for POST requests. | |
| void | onWs (MessageHandler handler) |
| Set handler for WebSocket requests. | |
| std::optional< std::string > | run () |
| Run the server. | |
| void | stop (boost::asio::yield_context yield) |
| Stop the server. This method will asynchronously sleep unless all the users are disconnected. | |
Web server class.
| using web::ng::Server::OnIpChangeHook = impl::ConnectionHandler::OnIpChangeHook |
Hook called when a connection's client ip changes (e.g. resolved from a proxy).
The hook receives the old ip and the new ip.
| web::ng::Server::Server | ( | boost::asio::io_context & | ctx, |
| boost::asio::ip::tcp::endpoint | endpoint, | ||
| std::optional< boost::asio::ssl::context > | sslContext, | ||
| ProcessingPolicy | processingPolicy, | ||
| std::optional< size_t > | parallelRequestLimit, | ||
| util::TagDecoratorFactory | tagDecoratorFactory, | ||
| ProxyIpResolver | proxyIpResolver, | ||
| size_t | maxSubscriptionSendQueueSize, | ||
| Hooks | hooks ) |
Construct a new Server object.
| ctx | The boost::asio::io_context to use. |
| endpoint | The endpoint to listen on. |
| sslContext | The SSL context to use (optional). |
| processingPolicy | The requests processing policy (parallel or sequential). |
| parallelRequestLimit | The limit of requests for one connection that can be processed in parallel. Only used if processingPolicy is parallel. |
| tagDecoratorFactory | The tag decorator factory. |
| proxyIpResolver | The client ip resolver if a request was forwarded by a proxy |
| maxSubscriptionSendQueueSize | The maximum size of the subscription send queue. |
| hooks | The server hooks |
| void web::ng::Server::onGet | ( | std::string const & | target, |
| MessageHandler | handler ) |
Set handler for GET requests.
| target | The target of the request. |
| handler | The handler to set. |
| void web::ng::Server::onPost | ( | std::string const & | target, |
| MessageHandler | handler ) |
Set handler for POST requests.
| target | The target of the request. |
| handler | The handler to set. |
| void web::ng::Server::onWs | ( | MessageHandler | handler | ) |
Set handler for WebSocket requests.
| handler | The handler to set. |
| std::optional< std::string > web::ng::Server::run | ( | ) |
Run the server.
| void web::ng::Server::stop | ( | boost::asio::yield_context | yield | ) |
Stop the server. This method will asynchronously sleep unless all the users are disconnected.
| yield | The coroutine context. |