Skip to content

sgns::api::HttpSession

HTTP session for api service.

#include <http_session.hpp>

Inherits from sgns::api::Session, std::enable_shared_from_this< HttpSession >

Public Classes

Name
struct Configuration

Public Functions

Name
~HttpSession() override =default
HttpSession(Context & context, Configuration config)
constructor
virtual Socket & socket() override
virtual void start() override
starts session
virtual void respond(std::string_view response) override
sends response wrapped by http message
virtual SessionId id() const override
method to get id of the session
virtual SessionType type() const override
method to get type of the session
template <class Body >
void
handleRequest(boost::beast::http::request< Body > && req)

Additional inherited members

Public Types inherited from sgns::api::Session

Name
using RpcContext Context
using boost::asio::ip::tcp::socket Socket
using boost::system::error_code ErrorCode
using boost::asio::streambuf Streambuf
using boost::asio::steady_timer Timer
using boost::signals2::connection Connection
using Timer::duration Duration
using uint64_t SessionId
using std::function< void(SessionId, SessionType)> OnCloseHandler
Event handlers.

Public Functions inherited from sgns::api::Session

Name
virtual ~Session() =default
void connectOnRequest(std::function< OnRequestSignature > callback)
connects on request callback
void connectOnCloseHandler(OnCloseHandler && handler)
connects on close callback
void processRequest(std::string_view request, std::shared_ptr< Session > session)
process request message
void notifyOnClose(SessionId id, SessionType type)
makes on close notification to listener

Public Functions Documentation

function ~HttpSession

~HttpSession() override =default

function HttpSession

HttpSession(
    Context & context,
    Configuration config
)

constructor

Parameters:

  • context session context
  • config session configuration

function socket

inline virtual Socket & socket() override

Reimplements: sgns::api::Session::socket

function start

virtual void start() override

starts session

Reimplements: sgns::api::Session::start

function respond

virtual void respond(
    std::string_view response
) override

sends response wrapped by http message

Parameters:

  • response message to send

Reimplements: sgns::api::Session::respond

function id

inline virtual SessionId id() const override

method to get id of the session

Return: id of the session

Reimplements: sgns::api::Session::id

function type

inline virtual SessionType type() const override

method to get type of the session

Return: type of the session

Reimplements: sgns::api::Session::type

function handleRequest

template <class Body >
void handleRequest(
    boost::beast::http::request< Body > && req
)

Updated on 2026-03-04 at 13:10:43 -0800