mirror of
https://github.com/matrix-construct/construct
synced 2024-10-03 06:08:52 +02: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"
|
"You are not permitted to view this event"
|
||||||
};
|
};
|
||||||
|
|
||||||
const unique_buffer<mutable_buffer> buffer
|
|
||||||
{
|
|
||||||
64_KiB
|
|
||||||
};
|
|
||||||
|
|
||||||
const m::event::fetch event
|
const m::event::fetch event
|
||||||
{
|
{
|
||||||
event_id
|
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
|
||||||
{
|
{
|
||||||
{ "pdus", { &pdu, 1 } }
|
buf, [&response](const const_buffer &buf)
|
||||||
|
{
|
||||||
|
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
|
resource::method method_get
|
||||||
|
|
Loading…
Reference in a new issue