mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
modules: Reduce various chunked json buffer mgmt boilerplates.
This commit is contained in:
parent
660bfcc03f
commit
4f2e1a4acd
9 changed files with 15 additions and 105 deletions
|
@ -83,26 +83,14 @@ get__context(client &client,
|
|||
event_id
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
const auto flush{[&response]
|
||||
(const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, flush, size_t(flush_hiwat)
|
||||
response.buf, response.flusher(), size_t(flush_hiwat)
|
||||
};
|
||||
|
||||
json::stack::object ret
|
||||
|
|
|
@ -96,22 +96,15 @@ get__messages(client &client,
|
|||
room, page.from, &default_fetch_opts
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack out{buf, [&response]
|
||||
(const const_buffer &buf)
|
||||
json::stack out
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
response.buf, response.flusher()
|
||||
};
|
||||
|
||||
json::stack::object ret
|
||||
{
|
||||
|
|
|
@ -95,26 +95,14 @@ get__backfill(client &client,
|
|||
room_id, event_id
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
const auto flush{[&response]
|
||||
(const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, flush, size_t(backfill_flush_hiwat)
|
||||
response.buf, response.flusher(), size_t(backfill_flush_hiwat)
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
|
|
|
@ -96,22 +96,15 @@ get__backfill_ids(client &client,
|
|||
room
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
4_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack out{buf, [&response]
|
||||
(const const_buffer &buf)
|
||||
json::stack out
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
response.buf, response.flusher()
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
json::stack::member pdus_m
|
||||
|
|
|
@ -49,11 +49,6 @@ handle_get(client &client,
|
|||
event_id
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
|
@ -61,11 +56,7 @@ handle_get(client &client,
|
|||
|
||||
json::stack out
|
||||
{
|
||||
buf, [&response](const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}
|
||||
response.buf, response.flusher()
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
|
|
|
@ -80,26 +80,14 @@ get__event_auth(client &client,
|
|||
room
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
const auto flush{[&response]
|
||||
(const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, flush, size_t(event_auth_flush_hiwat)
|
||||
response.buf, response.flusher(), size_t(event_auth_flush_hiwat)
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
|
|
|
@ -108,26 +108,14 @@ get__missing_events(client &client,
|
|||
});
|
||||
}};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
const auto flush{[&response]
|
||||
(const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, flush, size_t(flush_hiwat)
|
||||
response.buf, response.flusher(), size_t(flush_hiwat)
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
|
|
|
@ -62,26 +62,14 @@ get__state(client &client,
|
|||
room
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
96_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
const auto flush{[&response]
|
||||
(const const_buffer &buf)
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, flush, size_t(state_flush_hiwat)
|
||||
response.buf, response.flusher(), size_t(state_flush_hiwat)
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
|
|
|
@ -55,22 +55,15 @@ get__state_ids(client &client,
|
|||
room
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
8_KiB
|
||||
};
|
||||
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack out{buf, [&response]
|
||||
(const const_buffer &buf)
|
||||
json::stack out
|
||||
{
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}};
|
||||
response.buf, response.flusher()
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
json::stack::member pdus_m
|
||||
|
|
Loading…
Reference in a new issue