0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-26 02:18:53 +02:00

ircd::resource::response::chunked: Add convenience amalgam w/ json::stack, top json::object.

This commit is contained in:
Jason Volk 2021-01-02 19:12:40 -08:00
parent d52d6bc042
commit 2c1f9e5162

View file

@ -84,6 +84,8 @@ struct ircd::resource::response
struct ircd::resource::response::chunked
:resource::response
{
struct json;
static conf::item<size_t> default_buffer_size;
client *c {nullptr};
@ -111,3 +113,39 @@ struct ircd::resource::response::chunked
chunked &operator=(const chunked &&) = delete;
~chunked() noexcept;
};
/// Convenience amalgam. This class reduces a common pattern of objects
/// constructed in a response handler using chunked encoding to stream
/// json::object content.
///
struct ircd::resource::response::chunked::json
:resource::response::chunked
{
ircd::json::stack out;
ircd::json::stack::object top;
operator ircd::json::stack &()
{
return out;
}
template<class... args>
json(args&&... a);
};
template<class... args>
inline
ircd::resource::response::chunked::json::json(args&&... a)
:resource::response::chunked
{
std::forward<args>(a)...
}
,out
{
this->buf, this->flusher()
}
,top
{
this->out
}
{}