tgbot-cpp
Loading...
Searching...
No Matches
TgBot::HttpServer< Protocol > Class Template Reference

This class handles HTTP requests from the Internet. More...

#include <HttpServer.h>

Inheritance diagram for TgBot::HttpServer< Protocol >:
TgBot::TgWebhookServer< Protocol >

Public Types

using ServerHandler = std::function<std::string(const std::string&, const std::unordered_map<std::string, std::string>&)>
using ErrorHandler = std::function<void(const std::exception&)>

Public Member Functions

 HttpServer (const typename boost::asio::basic_socket_acceptor< Protocol >::endpoint_type &endpoint, ServerHandler handler)
void start (const ErrorHandler &errorHandler={ }, std::initializer_list< int > signals={ SIGINT, SIGTERM })
 Starts receiving connections until stop() is called or one of the configured signals is received.
void stop ()
 Stops receiving new connections. Connections already accepted are completed.

Detailed Description

template<typename Protocol>
class TgBot::HttpServer< Protocol >

This class handles HTTP requests from the Internet.

Definition at line 27 of file HttpServer.h.

Member Typedef Documentation

◆ ErrorHandler

template<typename Protocol>
using TgBot::HttpServer< Protocol >::ErrorHandler = std::function<void(const std::exception&)>

Definition at line 30 of file HttpServer.h.

◆ ServerHandler

template<typename Protocol>
using TgBot::HttpServer< Protocol >::ServerHandler = std::function<std::string(const std::string&, const std::unordered_map<std::string, std::string>&)>

Definition at line 29 of file HttpServer.h.

Constructor & Destructor Documentation

◆ HttpServer()

template<typename Protocol>
TgBot::HttpServer< Protocol >::HttpServer ( const typename boost::asio::basic_socket_acceptor< Protocol >::endpoint_type & endpoint,
ServerHandler handler )
inline

Definition at line 32 of file HttpServer.h.

Member Function Documentation

◆ start()

template<typename Protocol>
void TgBot::HttpServer< Protocol >::start ( const ErrorHandler & errorHandler = { },
std::initializer_list< int > signals = { SIGINT, SIGTERM } )
inline

Starts receiving connections until stop() is called or one of the configured signals is received.

Parameters
errorHandlerCalled when receiving or handling a request fails.
signalsProcess signals that stop the server. Pass an empty list to disable signal handling.

Definition at line 43 of file HttpServer.h.

◆ stop()

template<typename Protocol>
void TgBot::HttpServer< Protocol >::stop ( )
inline

Stops receiving new connections. Connections already accepted are completed.

Definition at line 72 of file HttpServer.h.


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