identt
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
identt::http::HttpServerBase< socket_type > Class Template Referenceabstract
Inheritance diagram for identt::http::HttpServerBase< socket_type >:
identt::http::HttpServer< socket_type >

Classes

class  Config
 
class  Connection
 
struct  Connections
 
class  Content
 
class  Request
 
class  Response
 Response class where the content of the response is sent to client when the object is about to be destroyed. More...
 
class  Session
 

Public Types

using RespPtr = std::shared_ptr< Response >
 
using ReqPtr = std::shared_ptr< Request >
 

Public Member Functions

unsigned short bind ()
 If you know the server port in advance, use start() instead. More...
 
void accept_and_run ()
 If you know the server port in advance, use start() instead. More...
 
void start ()
 Start the server by calling bind() and accept_and_run()
 
void stop () noexcept
 Stop accepting new requests, and close current connections.
 

Public Attributes

Config config
 Set before calling start().
 
std::map< regex_orderable, std::map< std::string, std::function< void(std::shared_ptr< typename HttpServerBase< socket_type >::Response >, std::shared_ptr< typename HttpServerBase< socket_type >::Request >)> > > resource
 Use this container to add resources for specific request paths depending on the given regex and method. More...
 
std::map< std::string, std::function< void(std::shared_ptr< typename HttpServerBase< socket_type >::Response >, std::shared_ptr< typename HttpServerBase< socket_type >::Request >)> > default_resource
 If the request path does not match a resource regex, this function is called.
 
std::function< void(std::shared_ptr< typename HttpServerBase< socket_type >::Request >, const error_code &)> on_error
 Called when an error occurs.
 
std::function< void(std::unique_ptr< socket_type > &, std::shared_ptr< typename HttpServerBase< socket_type >::Request >)> on_upgrade
 Called on upgrade requests.
 
std::shared_ptr<::identt::http::io_whatever > io_whatever
 If you want to reuse an already created asio::io_service, store its pointer here before calling start().
 

Protected Member Functions

 HttpServerBase (unsigned short port) noexcept
 
virtual void after_bind ()
 
virtual void accept ()=0
 
template<typename... Args>
std::shared_ptr< Connectioncreate_connection (Args &&... args) noexcept
 
void read (const std::shared_ptr< Session > &session)
 
void read_chunked_transfer_encoded (const std::shared_ptr< Session > &session, const std::shared_ptr< asio::streambuf > &chunks_streambuf)
 
void read_chunked_transfer_encoded_chunk (const std::shared_ptr< Session > &session, const std::shared_ptr< asio::streambuf > &chunks_streambuf, unsigned long length)
 
void find_resource (const std::shared_ptr< Session > &session)
 
void write (const std::shared_ptr< Session > &session, std::function< void(std::shared_ptr< typename HttpServerBase< socket_type >::Response >, std::shared_ptr< typename HttpServerBase< socket_type >::Request >)> &resource_function)
 

Protected Attributes

std::mutex start_stop_mutex
 
std::unique_ptr< asio::ip::tcp::acceptor > acceptor
 
std::shared_ptr< Connectionsconnections
 
std::shared_ptr< ScopeRunnerhandler_runner
 

Member Function Documentation

§ accept_and_run()

template<class socket_type>
void identt::http::HttpServerBase< socket_type >::accept_and_run ( )
inline

If you know the server port in advance, use start() instead.

Call after bind().

§ bind()

template<class socket_type>
unsigned short identt::http::HttpServerBase< socket_type >::bind ( )
inline

If you know the server port in advance, use start() instead.

Returns assigned port. Call before accept_and_run().

Member Data Documentation

§ resource

template<class socket_type>
std::map<regex_orderable, std::map<std::string, std::function<void(std::shared_ptr<typename HttpServerBase<socket_type>::Response>, std::shared_ptr<typename HttpServerBase<socket_type>::Request>)> > > identt::http::HttpServerBase< socket_type >::resource

Use this container to add resources for specific request paths depending on the given regex and method.

Warning: do not add or remove resources after start() is called


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