0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::resource: Accept json::member for response for now.

This commit is contained in:
Jason Volk 2017-09-08 08:15:14 -07:00
parent dd12f013cf
commit db748cae81
10 changed files with 20 additions and 32 deletions

View file

@ -93,8 +93,8 @@ struct ircd::resource::response
{
response(client &, const string_view &str, const string_view &ct = "text/plain; charset=utf8", const http::code & = http::OK);
response(client &, const json::object & = "{}", const http::code & = http::OK);
response(client &, const json::index &, const http::code & = http::OK);
response(client &, const http::code &, const json::index &);
response(client &, const json::members &, const http::code & = http::OK);
response(client &, const http::code &, const json::members &);
response() = default;
};

View file

@ -247,24 +247,19 @@ ircd::resource::request::request(const http::request::head &head,
ircd::resource::response::response(client &client,
const http::code &code,
const json::index &idx)
:response{client, idx, code}
const json::members &members)
:response{client, members, code}
{
}
ircd::resource::response::response(client &client,
const json::index &index,
const json::members &members,
const http::code &code)
try
{
char cbuf[8192];
mutable_buffer buf{cbuf};
const json::object object
{
stringify(buf, index)
};
response(client, object, code);
char buf[8192];
const auto sv(stringify(buf, members));
response(client, json::object{sv}, code);
}
catch(const json::error &e)
{

View file

@ -75,9 +75,9 @@ try
*/
return resource::response
{
client, http::CREATED, json::index
client, http::CREATED,
{
{ "room_id", string_view{room_id} }
{ "room_id", string_view{room_id} }
}
};
}

View file

@ -61,18 +61,11 @@ get_events(client &client, const resource::request &request)
});
char buf[16384];
char *start{buf};
char *const stop{buf + sizeof(buf)};
const auto chunk
{
json::serialize(jo, start, stop)
};
return resource::response
{
client, json::index
client,
{
{ "chunk", string_view{chunk} }
{ "chunk", json::stringify(buf, jo) }
}
};
}

View file

@ -39,7 +39,7 @@ logout(client &client, const resource::request &request)
resource::tokens.erase(it);
return resource::response
{
client, json::index
client,
{
{ }
}

View file

@ -33,7 +33,7 @@ get_publicrooms(client &client, const resource::request &request)
{
return resource::response
{
client, json::index
client,
{
{ }
}

View file

@ -36,7 +36,7 @@ try
{
return resource::response
{
client, json::index
client,
{
{ }
}

View file

@ -162,7 +162,7 @@ handle_post_kind_user(client &client,
// Send response to user
return resource::response
{
client, http::CREATED, json::index
client, http::CREATED,
{
{ "user_id", user_id },
{ "home_server", home_server },
@ -183,7 +183,7 @@ handle_post_kind_guest(client &client,
return resource::response
{
client, http::CREATED, json::index
client, http::CREATED,
{
{ "user_id", user_id },
{ "home_server", home_server },

View file

@ -54,7 +54,7 @@ try
return resource::response
{
client, json::index
client,
{
{ }
}
@ -123,7 +123,7 @@ try
return resource::response
{
client, http::CREATED, json::index
client, http::CREATED,
{
{ "filter_id", "abc321" }
}

View file

@ -38,7 +38,7 @@ get_turnserver(client &client, const resource::request &request)
{
return resource::response
{
client, json::index
client,
{
{ },
}