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§async fn from_request_parts(
parts: &mut Parts,
state: &S,
) -> Result<Self, Self::Rejection>
async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<Self, Self::Rejection>
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 ...
}Source§impl TryFrom<&Request> for PathAndQuery
impl TryFrom<&Request> for PathAndQuery
Source§type Error = InvalidUri
type Error = InvalidUri
Source§fn try_from(query: &WebFingerRequest) -> Result<PathAndQuery, InvalidUri>
fn try_from(query: &WebFingerRequest) -> Result<PathAndQuery, InvalidUri>
impl Eq for Request
impl StructuralPartialEq for Request
Auto Trait Implementations§
impl !Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.