Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
web Namespace Reference

This namespace implements the web server and related components. More...

Classes

class  AdminVerificationStrategy
 Interface for admin verification strategies. More...
 
struct  ConnectionBase
 Base class for all connections. More...
 
struct  Context
 Context that is used by the Webserver to pass around information about an incoming request. More...
 
class  Detector
 The Detector class to detect if the connection is a ssl or not. More...
 
class  HttpSession
 Represents a HTTP connection established by a client. More...
 
class  IPAdminVerificationStrategy
 Admin verification strategy that checks the ip address of the client. More...
 
class  PasswordAdminVerificationStrategy
 Admin verification strategy that checks the password from the request header. More...
 
class  PlainWsSession
 Represents a non-secure websocket session. More...
 
class  Resolver
 Simple hostnames to IP addresses resolver. More...
 
class  RPCServerHandler
 The server handler for RPC requests called by web server. More...
 
class  Server
 The WebServer class. It creates server socket and start listening on it. More...
 
class  SslHttpSession
 Represents a HTTPS connection established by a client. More...
 
class  SslWsSession
 Represents a secure websocket session. More...
 
class  SslWsUpgrader
 The HTTPS upgrader class, upgrade from an HTTPS session to a secure websocket session. More...
 
class  SubscriptionContext
 A context of a WsBase connection for subscriptions. More...
 
class  SubscriptionContextInterface
 An interface to provide connection functionality for subscriptions. More...
 
class  WsUpgrader
 The websocket upgrader class, upgrade from an HTTP session to a non-secure websocket session. More...
 

Concepts

concept  SomeServerHandler
 Specifies the requirements a Webserver handler must fulfill.
 
concept  SomeResolver
 The requirements of a resolver.
 

Typedefs

using tcp = boost::asio::ip::tcp
 
template<typename HandlerType >
using HttpServer = Server<HttpSession, SslHttpSession, HandlerType>
 The final type of the HttpServer used by Clio.
 
using SubscriptionContextPtr = std::shared_ptr<SubscriptionContextInterface>
 An alias for shared pointer to a SubscriptionContextInterface.
 

Functions

std::shared_ptr< AdminVerificationStrategymakeAdminVerificationStrategy (std::optional< std::string > password)
 Factory function for creating an admin verification strategy.
 
std::expected< std::shared_ptr< AdminVerificationStrategy >, std::string > makeAdminVerificationStrategy (util::config::ClioConfigDefinition const &serverConfig)
 Factory function for creating an admin verification strategy from server config.
 
template<typename HandlerType >
static std::shared_ptr< HttpServer< HandlerType > > makeHttpServer (util::config::ClioConfigDefinition const &config, boost::asio::io_context &ioc, dosguard::DOSGuardInterface &dosGuard, std::shared_ptr< HandlerType > const &handler)
 A factory function that spawns a ready to use HTTP server.
 

Detailed Description

This namespace implements the web server and related components.

The web server is leveraging the power of boost::asio with it's coroutine support thru boost::asio::yield_context and boost::asio::spawn.

Majority of the code is based on examples that came with boost.

Function Documentation

◆ makeAdminVerificationStrategy() [1/2]

std::shared_ptr< AdminVerificationStrategy > web::makeAdminVerificationStrategy ( std::optional< std::string > password)

Factory function for creating an admin verification strategy.

Parameters
passwordThe optional password to check.
Returns
Admin verification strategy. If password is provided, it will be PasswordAdminVerificationStrategy. Otherwise, it will be IPAdminVerificationStrategy.

◆ makeAdminVerificationStrategy() [2/2]

std::expected< std::shared_ptr< AdminVerificationStrategy >, std::string > web::makeAdminVerificationStrategy ( util::config::ClioConfigDefinition const & serverConfig)

Factory function for creating an admin verification strategy from server config.

Parameters
serverConfigThe clio config.
Returns
Admin verification strategy according to the config or an error message.

◆ makeHttpServer()

template<typename HandlerType >
static std::shared_ptr< HttpServer< HandlerType > > web::makeHttpServer ( util::config::ClioConfigDefinition const & config,
boost::asio::io_context & ioc,
dosguard::DOSGuardInterface & dosGuard,
std::shared_ptr< HandlerType > const & handler )
static

A factory function that spawns a ready to use HTTP server.

Template Parameters
HandlerTypeThe tyep of handler to process the request
Parameters
configThe config to create server
iocThe server will run under this io_context
dosGuardThe dos guard to protect the server
handlerThe handler to process the request
Returns
The server instance