roar
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Roar::Server Class Reference

#include <server.hpp>

Collaboration diagram for Roar::Server:

Classes

struct  ConstructionArguments
 
struct  Implementation
 

Public Member Functions

 Server (ConstructionArguments constructionArgs)
 Construct a new Server object given a boost asio io_executor.
 
 ~Server ()
 
 Server (Server const &)=delete
 
 Server (Server &&)
 
Serveroperator= (Server const &)=delete
 
Serveroperator= (Server &&)
 
boost::leaf::result< void > start (unsigned short port=0, std::string const &host="::")
 Bind and listen for network interface and port.
 
boost::leaf::result< void > start (boost::asio::ip::basic_endpoint< boost::asio::ip::tcp > const &bindEndpoint)
 Starts the server given the already resolved bind endpoint.
 
boost::asio::ip::basic_endpoint< boost::asio::ip::tcp > const & getLocalEndpoint () const
 Get the local endpoint that this server bound to.
 
void stop ()
 Stop and shutdown the server.
 
template<typename RequestListenerT , typename... ConstructionArgsT>
std::shared_ptr< RequestListenerT > installRequestListener (ConstructionArgsT &&... args)
 Attach a request listener to this server to receive requests.
 
bool isSecure () const
 Returns whether this server has a certificate and key and is therefore a HTTPS server.
 
boost::asio::any_io_executor getExecutor () const
 Get the Executor object.
 

Private Member Functions

template<typename RequestListenerT >
void addRoute (std::shared_ptr< RequestListenerT > listener, std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &extractedRoutes, RouteInfo< RequestListenerT > const &info)
 
template<typename RequestListenerT >
void addRoute (std::shared_ptr< RequestListenerT > listener, std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &extractedRoutes, ServeInfo< RequestListenerT > const &info)
 
void addRequestListenerToRouter (std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &&routes)
 

Private Attributes

std::shared_ptr< Implementationimpl_
 

Constructor & Destructor Documentation

◆ Server() [1/3]

Roar::Server::Server ( ConstructionArguments  constructionArgs)

Construct a new Server object given a boost asio io_executor.

Parameters
constructionArgsOptions to construct the server with

◆ ~Server()

Roar::Server::~Server ( )

◆ Server() [2/3]

Roar::Server::Server ( Server const &  )
delete

◆ Server() [3/3]

Roar::Server::Server ( Server &&  )
default

Member Function Documentation

◆ addRequestListenerToRouter()

void Roar::Server::addRequestListenerToRouter ( std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &&  routes)
private

◆ addRoute() [1/2]

template<typename RequestListenerT >
void Roar::Server::addRoute ( std::shared_ptr< RequestListenerT >  listener,
std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &  extractedRoutes,
RouteInfo< RequestListenerT > const &  info 
)
inlineprivate

◆ addRoute() [2/2]

template<typename RequestListenerT >
void Roar::Server::addRoute ( std::shared_ptr< RequestListenerT >  listener,
std::unordered_multimap< boost::beast::http::verb, ProtoRoute > &  extractedRoutes,
ServeInfo< RequestListenerT > const &  info 
)
inlineprivate

◆ getExecutor()

boost::asio::any_io_executor Roar::Server::getExecutor ( ) const

Get the Executor object.

Returns
boost::asio::any_io_executor& The ASIO any_io_executor.

◆ getLocalEndpoint()

boost::asio::ip::basic_endpoint< boost::asio::ip::tcp > const & Roar::Server::getLocalEndpoint ( ) const

Get the local endpoint that this server bound to.

Returns
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&

◆ installRequestListener()

template<typename RequestListenerT , typename... ConstructionArgsT>
std::shared_ptr< RequestListenerT > Roar::Server::installRequestListener ( ConstructionArgsT &&...  args)
inline

Attach a request listener to this server to receive requests.

Parameters
listener

◆ isSecure()

bool Roar::Server::isSecure ( ) const

Returns whether this server has a certificate and key and is therefore a HTTPS server.

Returns
true is HTTPS.
false is not HTTPS.

◆ operator=() [1/2]

Server & Roar::Server::operator= ( Server &&  )
default

◆ operator=() [2/2]

Server & Roar::Server::operator= ( Server const &  )
delete

◆ start() [1/2]

boost::leaf::result< void > Roar::Server::start ( boost::asio::ip::basic_endpoint< boost::asio::ip::tcp > const &  bindEndpoint)

Starts the server given the already resolved bind endpoint.

Parameters
bindEndpointAn endpoint to bind on.

◆ start() [2/2]

boost::leaf::result< void > Roar::Server::start ( unsigned short  port = 0,
std::string const &  host = "::" 
)

Bind and listen for network interface and port.

Parameters
hostAn ip / hostname to identify the network interface to listen on.
portA port to bind on.

◆ stop()

void Roar::Server::stop ( )

Stop and shutdown the server.

Member Data Documentation

◆ impl_

std::shared_ptr<Implementation> Roar::Server::impl_
private

The documentation for this class was generated from the following files: