View in context in the libbitcoin Slack #general mirror.
json serialization (which also requires a buffer) buffer control is maintained by its exposure on the http::json::body object, accessible to the caller as response::body().buffer. In both cases this allows the channel to reuse a single buffer for all reads and for json writes for a given channel instance. So dynamic allocation can be eliminated, allowing the buffers to remain stack allocated. If the json serialization buffer is not provided, it will get allocated at a hardwired size internally. The payload object here is provided by the boost::beast construction of the request/response as the .body().
struct payload
{
/// JSON DOM.
json_value model{};
/// Writer serialization buffer (max size, allocated on write).
mutable http::flat_buffer_ptr buffer{};
};