mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
update ggemini
api
This commit is contained in:
parent
c64bb628f2
commit
9d4f2a2cbf
@ -50,20 +50,20 @@ pub fn handle(
|
|||||||
Status::Input => callback(Response::Input(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.to_gstring(),
|
||||||
None => "Input expected".into(),
|
None => "Input expected".into(),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
Status::SensitiveInput => callback(Response::Input(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.to_gstring(),
|
||||||
None => "Input expected".into(),
|
None => "Input expected".into(),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-20
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-20
|
||||||
Status::Success => {
|
Status::Success => {
|
||||||
let mime = response.meta.mime.unwrap().value.to_lowercase();
|
let mime = response.meta.mime.unwrap(); // @TODO handle
|
||||||
match mime.as_str() {
|
match mime.as_str() {
|
||||||
"text/gemini" => Text::from_stream_async(
|
"text/gemini" => Text::from_stream_async(
|
||||||
response.connection.stream(),
|
response.connection.stream(),
|
||||||
@ -81,7 +81,7 @@ pub fn handle(
|
|||||||
"image/png" | "image/gif" | "image/jpeg" | "image/webp" => {
|
"image/png" | "image/gif" | "image/jpeg" | "image/webp" => {
|
||||||
callback(Response::Stream {
|
callback(Response::Stream {
|
||||||
base,
|
base,
|
||||||
mime,
|
mime: mime.to_string(),
|
||||||
stream: response.connection.stream(),
|
stream: response.connection.stream(),
|
||||||
cancellable,
|
cancellable,
|
||||||
})
|
})
|
||||||
@ -95,7 +95,7 @@ pub fn handle(
|
|||||||
}
|
}
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-30-temporary-redirection
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-30-temporary-redirection
|
||||||
Status::Redirect => callback(match response.meta.data {
|
Status::Redirect => callback(match response.meta.data {
|
||||||
Some(data) => match Uri::parse_relative(&base, &data.value, UriFlags::NONE) {
|
Some(data) => match Uri::parse_relative(&base, data.as_str(), UriFlags::NONE) {
|
||||||
Ok(target) => Response::Redirect(Redirect::Foreground {
|
Ok(target) => Response::Redirect(Redirect::Foreground {
|
||||||
source: base,
|
source: base,
|
||||||
target,
|
target,
|
||||||
@ -110,7 +110,7 @@ pub fn handle(
|
|||||||
}), // @TODO validate redirect count
|
}), // @TODO validate redirect count
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection
|
||||||
Status::PermanentRedirect => callback(match response.meta.data {
|
Status::PermanentRedirect => callback(match response.meta.data {
|
||||||
Some(data) => match Uri::parse_relative(&base, &data.value, UriFlags::NONE) {
|
Some(data) => match Uri::parse_relative(&base, data.as_str(), UriFlags::NONE) {
|
||||||
Ok(target) => Response::Redirect(Redirect::Background {
|
Ok(target) => Response::Redirect(Redirect::Background {
|
||||||
source: base,
|
source: base,
|
||||||
target,
|
target,
|
||||||
@ -126,7 +126,7 @@ pub fn handle(
|
|||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
||||||
Status::CertificateRequest => callback(Response::Certificate(Certificate::Request {
|
Status::CertificateRequest => callback(Response::Certificate(Certificate::Request {
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.to_gstring(),
|
||||||
None => "Client certificate required".into(),
|
None => "Client certificate required".into(),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
@ -134,7 +134,7 @@ pub fn handle(
|
|||||||
Status::CertificateUnauthorized => {
|
Status::CertificateUnauthorized => {
|
||||||
callback(Response::Certificate(Certificate::Request {
|
callback(Response::Certificate(Certificate::Request {
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.to_gstring(),
|
||||||
None => "Certificate not authorized".into(),
|
None => "Certificate not authorized".into(),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
@ -142,7 +142,7 @@ 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 => callback(Response::Certificate(Certificate::Request {
|
Status::CertificateInvalid => callback(Response::Certificate(Certificate::Request {
|
||||||
title: match response.meta.data {
|
title: match response.meta.data {
|
||||||
Some(data) => data.value,
|
Some(data) => data.to_gstring(),
|
||||||
None => "Certificate not valid".into(),
|
None => "Certificate not valid".into(),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user