update example

This commit is contained in:
yggverse 2025-02-03 02:09:41 +02:00
parent dc2300b1c0
commit 517153656b

View file

@ -42,12 +42,10 @@ cargo add ggemini
use gio::*; use gio::*;
use glib::*; use glib::*;
use ggemini::client::{ use ggemini::client::{
connection::{ connection::{response::Success, Request, Response},
Request, Response, Client,
response::meta::{Mime, Status}
},
Client, Error,
}; };
fn main() -> ExitCode { fn main() -> ExitCode {
@ -58,20 +56,17 @@ fn main() -> ExitCode {
Priority::DEFAULT, Priority::DEFAULT,
Cancellable::new(), Cancellable::new(),
None, // optional `GTlsCertificate` None, // optional `GTlsCertificate`
|result: Result<Response, Error>| match result { |result| match result {
Ok(response) => { Ok((response, _connection)) => match response {
// route by status code Response::Success(success) => match success {
match response.meta.status { Success::Default { mime } => match mime.as_str() {
// code 20, handle `GIOStream` by content type
Status::Success => match response.meta.mime.unwrap().as_str() {
// gemtext, see ggemtext crate to parse
"text/gemini" => todo!(), "text/gemini" => todo!(),
// other content types
_ => todo!(), _ => todo!(),
}, },
_ => todo!(), _ => todo!(),
} },
} _ => todo!(),
},
Err(_) => todo!(), Err(_) => todo!(),
}, },
); );