mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
modules/federation/event: Convert endpoint to use json::stack response.
This commit is contained in:
parent
7b9e5f944d
commit
fba300d900
1 changed files with 25 additions and 10 deletions
|
@ -44,28 +44,43 @@ handle_get(client &client,
|
|||
"You are not permitted to view this event"
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buffer
|
||||
{
|
||||
64_KiB
|
||||
};
|
||||
|
||||
const m::event::fetch event
|
||||
{
|
||||
event_id
|
||||
};
|
||||
|
||||
const json::value pdu
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
static_cast<const m::event &>(event)
|
||||
96_KiB
|
||||
};
|
||||
|
||||
return resource::response
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, json::members
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
buf, [&response](const const_buffer &buf)
|
||||
{
|
||||
{ "pdus", { &pdu, 1 } }
|
||||
response.write(buf);
|
||||
return buf;
|
||||
}
|
||||
};
|
||||
|
||||
json::stack::object top{out};
|
||||
json::stack::member pdus_m
|
||||
{
|
||||
top, "pdus"
|
||||
};
|
||||
|
||||
json::stack::array pdus
|
||||
{
|
||||
pdus_m
|
||||
};
|
||||
|
||||
pdus.append(event);
|
||||
return {};
|
||||
}
|
||||
|
||||
resource::method method_get
|
||||
|
|
Loading…
Add table
Reference in a new issue