network-experiment/bmrshared-web/lib/response_promise.cpp

28 lines
750 B
C++

// GNU Lesser General Public License v3.0
// Copyright (c) 2025 Bart Beumer <bart@4beumer.nl>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License v3.0 as published by
// the Free Software Foundation.
//
#include <bmrshared/response_promise.hpp>
using bmrshared::web::response_promise;
response_promise::response_promise(callback_on_response cbOnResponse)
: m_call_on_response(std::move(cbOnResponse))
{
}
response_promise::~response_promise()
{
if (m_response_writer)
{
m_call_on_response(
[r = m_response_writer](boost::beast::tcp_stream& stream)
{
r->write_response(stream);
});
}
}