draft gemtext route

This commit is contained in:
yggverse 2024-08-18 15:19:36 +03:00
parent af6b1efe32
commit a73bb3aea6
8 changed files with 118 additions and 9 deletions

View file

@ -96,15 +96,39 @@ void Page::update()
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
{
// Response
socket_connection->get_input_stream()->read_all_async( // | read_async
socket_connection->get_input_stream()->read_async( // | read_all_async
buffer,
sizeof(buffer) - 1,
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
{
content->set(
// Parse meta
auto meta = Glib::Regex::split_simple(
R"regex(^(\d+)?\s([\w]+\/[\w]+)?)regex",
buffer
);
// Route by status code
if (meta[1] == "20")
{
// Route by mime type
if (meta[2] == "text/gemini")
{
content->text_gemini(
buffer // @TODO
);
}
else
{
// @TODO exception
}
}
else
{
// @TODO exception
}
socket_connection->close();
}
);