mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-30 13:04:13 +00:00
update response message, use namespace
This commit is contained in:
parent
8266c07db7
commit
fe5eeb04f9
@ -1,4 +1,7 @@
|
|||||||
use super::{response, Driver, Response};
|
use super::{
|
||||||
|
response::{Certificate, Failure, Input},
|
||||||
|
Driver, Response,
|
||||||
|
};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::Cancellable,
|
gio::Cancellable,
|
||||||
glib::{gformat, Priority, Uri},
|
glib::{gformat, Priority, Uri},
|
||||||
@ -42,14 +45,14 @@ pub fn handle(
|
|||||||
match result {
|
match result {
|
||||||
Ok(response) => match response.meta.status {
|
Ok(response) => match response.meta.status {
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#input-expected
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#input-expected
|
||||||
Status::Input => callback(Response::Input(response::Input::Response {
|
Status::Input => callback(Response::Input(Input::Response {
|
||||||
base,
|
base,
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.value,
|
||||||
None => gformat!("Input expected"),
|
None => gformat!("Input expected"),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
Status::SensitiveInput => callback(Response::Input(response::Input::Sensitive {
|
Status::SensitiveInput => callback(Response::Input(Input::Sensitive {
|
||||||
base,
|
base,
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.value,
|
||||||
@ -81,8 +84,8 @@ pub fn handle(
|
|||||||
cancellable,
|
cancellable,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
mime => callback(Response::Failure(response::Failure::Mime {
|
mime => callback(Response::Failure(Failure::Mime {
|
||||||
message: format!("Undefined content type `{mime}`"),
|
message: format!("Content type `{mime}` yet not supported"),
|
||||||
})),
|
})),
|
||||||
} // @TODO handle `None`
|
} // @TODO handle `None`
|
||||||
}
|
}
|
||||||
@ -90,17 +93,15 @@ pub fn handle(
|
|||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection
|
||||||
Status::Redirect | Status::PermanentRedirect => todo!(),
|
Status::Redirect | Status::PermanentRedirect => todo!(),
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
||||||
Status::CertificateRequest => {
|
Status::CertificateRequest => callback(Response::Certificate(Certificate::Request {
|
||||||
callback(Response::Certificate(response::Certificate::Request {
|
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.value,
|
||||||
None => gformat!("Client certificate required"),
|
None => gformat!("Client certificate required"),
|
||||||
},
|
},
|
||||||
}))
|
})),
|
||||||
}
|
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-61-certificate-not-authorized
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-61-certificate-not-authorized
|
||||||
Status::CertificateUnauthorized => {
|
Status::CertificateUnauthorized => {
|
||||||
callback(Response::Certificate(response::Certificate::Request {
|
callback(Response::Certificate(Certificate::Request {
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.value,
|
||||||
None => gformat!("Certificate not authorized"),
|
None => gformat!("Certificate not authorized"),
|
||||||
@ -108,19 +109,17 @@ pub fn handle(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-62-certificate-not-valid
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-62-certificate-not-valid
|
||||||
Status::CertificateInvalid => {
|
Status::CertificateInvalid => callback(Response::Certificate(Certificate::Request {
|
||||||
callback(Response::Certificate(response::Certificate::Request {
|
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.value,
|
||||||
None => gformat!("Certificate not valid"),
|
None => gformat!("Certificate not valid"),
|
||||||
},
|
},
|
||||||
}))
|
})),
|
||||||
}
|
status => callback(Response::Failure(Failure::Status {
|
||||||
status => callback(Response::Failure(response::Failure::Status {
|
|
||||||
message: format!("Undefined status code `{:?}`", status), // @TODO implement display trait for `ggemini` lib
|
message: format!("Undefined status code `{:?}`", status), // @TODO implement display trait for `ggemini` lib
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
Err(e) => callback(Response::Failure(response::Failure::Error {
|
Err(e) => callback(Response::Failure(Failure::Error {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user