$darkmode
oak::Server Class Reference

#include <server.hpp>

Public Member Functions

 Server (const std::string &addr, int port)
 
 ~Server ()
 
void set_threads (int n)
 
void set_address (const std::string &addr)
 
void set_port (int port)
 
bool is_listening () const
 
void listen ()
 
cloe::Json endpoints_to_json (const std::vector< std::string > &endpoints) const
 
void stop ()
 
std::vector< std::string > endpoints () const
 

Protected Member Functions

void add_handler (const std::string &key, Handler h)
 

Protected Attributes

friend StaticRegistrar
 
friend LockedRegistrar
 
friend BufferRegistrar
 

Detailed Description

A Server accepts and serves endpoints for Handlers.

This is a convenience wrapper around ServerImpl.

Constructor & Destructor Documentation

◆ ~Server()

oak::Server::~Server ( )
inline

When a Server goes out of scope, it will stop listening for you if you haven't done so already.

Member Function Documentation

◆ add_handler()

void oak::Server::add_handler ( const std::string &  key,
Handler  h 
)
inlineprotected

Add a handler with the route muxer in the internal handler routine.

◆ endpoints()

std::vector<std::string> oak::Server::endpoints ( ) const
inline

Return a list of all registered endpoints.

◆ endpoints_to_json()

cloe::Json oak::Server::endpoints_to_json ( const std::vector< std::string > &  endpoints) const
inline

Return endpoint data in json format.

◆ is_listening()

bool oak::Server::is_listening ( ) const
inline

Returns whether the server has started and is currently listening.

◆ listen()

void oak::Server::listen ( )

Start the server.

◆ set_address()

void oak::Server::set_address ( const std::string &  addr)
inline

Set the address on which the server will listen.

  • Use 127.0.0.1 to only allow local connections.
  • Use 0.0.0.0 to listen on all interfaces. This will allow clients from the entire network to access this service, if the system firewall allows it.

◆ set_port()

void oak::Server::set_port ( int  port)
inline

Set the port on which to listen.

◆ set_threads()

void oak::Server::set_threads ( int  n)
inline

Set the number of threads used for listening to connections. This is the number of requests that can be handled simultaneously.

◆ stop()

void oak::Server::stop ( )

Stop the server.


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