mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
use current Request as referrer
This commit is contained in:
parent
4698d7dce1
commit
dd171dabe9
2 changed files with 65 additions and 66 deletions
|
|
@ -27,7 +27,7 @@ impl Request {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self` from featured string
|
||||
pub fn parse(query: &str, referrer: Option<Box<Self>>) -> Result<Self, Error> {
|
||||
pub fn parse(query: &str, referrer: Option<Self>) -> Result<Self, Error> {
|
||||
let (feature, request) = Feature::parse(query);
|
||||
|
||||
match Uri::parse(request, UriFlags::NONE) {
|
||||
|
|
@ -40,15 +40,18 @@ impl Request {
|
|||
pub fn from_uri(
|
||||
uri: Uri,
|
||||
feature: Option<Feature>,
|
||||
referrer: Option<Box<Self>>,
|
||||
referrer: Option<Self>,
|
||||
) -> Result<Self, Error> {
|
||||
match uri.scheme().as_str() {
|
||||
"gemini" => Ok(Self::Gemini {
|
||||
feature: feature.unwrap_or_default(),
|
||||
referrer,
|
||||
referrer: referrer.map(Box::new),
|
||||
uri,
|
||||
}),
|
||||
"titan" => Ok(Self::Titan {
|
||||
referrer: referrer.map(Box::new),
|
||||
uri,
|
||||
}),
|
||||
"titan" => Ok(Self::Titan { referrer, uri }),
|
||||
_ => Err(Error::Unsupported),
|
||||
}
|
||||
}
|
||||
|
|
@ -62,16 +65,9 @@ impl Request {
|
|||
cancellable: Cancellable,
|
||||
callback: impl FnOnce(Response) + 'static,
|
||||
) {
|
||||
match self {
|
||||
Self::Gemini {
|
||||
feature,
|
||||
referrer,
|
||||
uri,
|
||||
} => gemini::request(client, feature, uri, referrer, cancellable, callback),
|
||||
Self::Titan {
|
||||
referrer: _,
|
||||
uri: _,
|
||||
} => todo!(),
|
||||
match &self {
|
||||
Self::Gemini { .. } => gemini::request(client, self, cancellable, callback),
|
||||
Self::Titan { .. } => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +85,14 @@ impl Request {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get `Feature` reference for `Self`
|
||||
pub fn feature(&self) -> &Feature {
|
||||
match self {
|
||||
Request::Gemini { feature, .. } => feature,
|
||||
Request::Titan { .. } => &Feature::Default,
|
||||
}
|
||||
}
|
||||
|
||||
/// Recursively count referrers of `Self`
|
||||
/// * useful to apply redirection rules by protocol driver selected
|
||||
pub fn referrers(&self) -> usize {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue