pub struct WebFingerRequest {
pub resource: Uri,
pub host: String,
pub rels: Vec<Rel>,
}Expand description
A WebFinger request.
This represents the request portion of a WebFinger query that can be executed against a WebFinger server.
See RFC 7033 Section 4 for more information.
§Examples
use webfinger_rs::WebFingerRequest;
let request = WebFingerRequest::builder("acct:carol@example.com")?
.host("example.com")
.rel("http://webfinger.net/rel/profile-page")
.build();To execute the query, enable the reqwest feature and call query.execute().
let response = request.execute_reqwest().await?;Request can be used as an Axum extractor as it implements axum::extract::FromRequestParts.
use webfinger_rs::{WebFingerRequest, WebFingerResponse};
async fn handler(request: WebFingerRequest) -> WebFingerResponse {
// ... handle the request ...
}Fields§
§resource: UriQuery target.
This is the URI of the resource to query. It will be stored in the resource query
parameter.
TODO: This could be a newtype that represents the resource and makes it easier to extract
the values / parse into the right types (e.g. acct: URIs).
host: StringThe host to query
TODO: this might be better as an Option<Uri> or Option<Host> or something similar. When
the resource has a host part, it should be used unless this field is set.
rels: Vec<Rel>Link relation types
This is a list of link relation types to query for. Each link relation type will be stored
in a rel query parameter.
Implementations§
source§impl WebFingerRequest
impl WebFingerRequest
sourcepub async fn execute_reqwest(&self) -> Result<WebFingerResponse, Error>
Available on crate feature reqwest only.
pub async fn execute_reqwest(&self) -> Result<WebFingerResponse, Error>
reqwest only.Executes the WebFinger request.
§Examples
use webfinger_rs::WebFingerRequest;
let query = WebFingerRequest::builder("acct:carol@example.com")?
.host("example.com")
.rel("http://webfinger.net/rel/profile-page")
.build();
let response = query.execute_reqwest().await?;sourcepub async fn execute_reqwest_with_client(
&self,
client: &Client,
) -> Result<WebFingerResponse, Error>
Available on crate feature reqwest only.
pub async fn execute_reqwest_with_client( &self, client: &Client, ) -> Result<WebFingerResponse, Error>
reqwest only.Executes the WebFinger request with a custom reqwest client.
sourcepub fn try_into_reqwest(&self) -> Result<Request, Error>
Available on crate feature reqwest only.
pub fn try_into_reqwest(&self) -> Result<Request, Error>
reqwest only.Converts the WebFinger request into a reqwest request.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl FromRequest for WebFingerRequest
Available on crate feature actix only.
impl FromRequest for WebFingerRequest
actix only.source§impl<S: Send + Sync> FromRequestParts<S> for WebFingerRequest
Available on crate feature axum only.
impl<S: Send + Sync> FromRequestParts<S> for WebFingerRequest
axum only.source§fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
state: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
state: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Extracts a WebFingerRequest from the request parts.
§Errors
-
If the request is missing the
Hostheader, it will return a Bad Request response with the message “missing host”. -
If the
resourcequery parameter is missing or invalid, it will return a Bad Request response with the message “invalid resource: {error}”. -
If the
relquery parameter is invalid, it will return a Bad Request response with the message “invalid query string: {error}”.
See the axum example for more information.
§Example
use axum::response::IntoResponse;
use webfinger_rs::WebFingerRequest;
async fn handler(request: WebFingerRequest) -> impl IntoResponse {
let WebFingerRequest {
host,
resource,
rels,
} = request;
// ... your code to handle the webfinger request ...
}