Pass an owned FromRequest value
This commit is contained in:
parent
779b26e52e
commit
755ab59d4c
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-webfinger"
|
name = "actix-webfinger"
|
||||||
description = "Types and helpers to create and fetch Webfinger resources"
|
description = "Types and helpers to create and fetch Webfinger resources"
|
||||||
version = "0.3.0-alpha.0"
|
version = "0.3.0-alpha.1"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/Aardwolf/actix-webfinger"
|
repository = "https://git.asonix.dog/Aardwolf/actix-webfinger"
|
||||||
|
|
|
@ -15,7 +15,7 @@ First, add Actix Webfinger as a dependency
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.10.0-alpha.1"
|
actix = "0.10.0-alpha.1"
|
||||||
actix-web = "3.0.0-alpha.1"
|
actix-web = "3.0.0-alpha.1"
|
||||||
actix-webfinger = "0.3.0-alpha.0"
|
actix-webfinger = "0.3.0-alpha.1"
|
||||||
```
|
```
|
||||||
|
|
||||||
Then use it in your application
|
Then use it in your application
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl Resolver<Data<MyState>> for MyResolver {
|
||||||
fn find(
|
fn find(
|
||||||
account: &str,
|
account: &str,
|
||||||
domain: &str,
|
domain: &str,
|
||||||
state: &Data<MyState>,
|
state: Data<MyState>,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>> {
|
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>> {
|
||||||
let w = if domain == state.domain {
|
let w = if domain == state.domain {
|
||||||
Some(Webfinger::new(&format!("{}@{}", account, domain)))
|
Some(Webfinger::new(&format!("{}@{}", account, domain)))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
//! [dependencies]
|
//! [dependencies]
|
||||||
//! actix = "0.10.0-alpha.1"
|
//! actix = "0.10.0-alpha.1"
|
||||||
//! actix-web = "3.0.0-alpha.1"
|
//! actix-web = "3.0.0-alpha.1"
|
||||||
//! actix-webfinger = "0.3.0-alpha.0"
|
//! actix-webfinger = "0.3.0-alpha.1"
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Then use it in your application
|
//! Then use it in your application
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
//! fn find(
|
//! fn find(
|
||||||
//! account: &str,
|
//! account: &str,
|
||||||
//! domain: &str,
|
//! domain: &str,
|
||||||
//! state: &Data<MyState>,
|
//! state: S,
|
||||||
//! ) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>> {
|
//! ) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>> {
|
||||||
//! let w = if domain == state.domain {
|
//! let w = if domain == state.domain {
|
||||||
//! Some(Webfinger::new(&format!("{}@{}", account, domain)))
|
//! Some(Webfinger::new(&format!("{}@{}", account, domain)))
|
||||||
|
@ -356,7 +356,7 @@ where
|
||||||
fn find(
|
fn find(
|
||||||
account: &str,
|
account: &str,
|
||||||
domain: &str,
|
domain: &str,
|
||||||
state: &S,
|
state: S,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>>;
|
) -> Pin<Box<dyn Future<Output = Result<Option<Webfinger>, Self::Error>>>>;
|
||||||
|
|
||||||
fn endpoint(
|
fn endpoint(
|
||||||
|
@ -365,7 +365,7 @@ where
|
||||||
let WebfingerResource { account, domain } = query.into_inner().resource;
|
let WebfingerResource { account, domain } = query.into_inner().resource;
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
match Self::find(&account, &domain, &state).await? {
|
match Self::find(&account, &domain, state).await? {
|
||||||
Some(w) => Ok(w.respond()),
|
Some(w) => Ok(w.respond()),
|
||||||
None => Ok(HttpResponse::NotFound().finish()),
|
None => Ok(HttpResponse::NotFound().finish()),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue