Skip to content

Commit

Permalink
bump dmds
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Apr 23, 2024
1 parent aea035a commit 7ad3d6c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 43 deletions.
51 changes: 24 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2021"
axum = "0.7"
axum-macros = "0.4"
libaccount = { version = "0.1", git = "https://github.com/subitlab-buf/libaccount.git" }
dmds = "0.2"
dmds-tokio-fs = "0.2"
dmds = "0.4"
dmds-tokio-fs = "0.3"
tokio = { version = "1.35", features = [
"rt",
"macros",
Expand Down Expand Up @@ -39,7 +39,6 @@ thiserror = "1.0"
rand = "0.8"
siphasher = "1.0"
highway = "1.1"
async-trait = "0.1"
http-body-util = "0.1"

[dev-dependencies]
Expand Down
38 changes: 25 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,34 @@ impl Auth {
}
}

#[async_trait::async_trait]
impl<Io: IoHandle> axum::extract::FromRequestParts<Global<Io>> for Auth {
type Rejection = Error;

async fn from_request_parts(
parts: &mut axum::http::request::Parts,
_state: &Global<Io>,
) -> Result<Self, Self::Rejection> {
let raw = parts.headers.remove(Self::KEY).ok_or(Error::NotLoggedIn)?;
let (account, token) = raw
.to_str()?
.split_once(':')
.ok_or(Error::InvalidAuthHeader)?;
Ok(Self {
account: account.parse().map_err(|_| Error::InvalidAuthHeader)?,
token: token.to_owned(),
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut axum::http::request::Parts,
_state: &'life1 Global<Io>,
) -> core::pin::Pin<
Box<
dyn core::future::Future<Output = Result<Self, Self::Rejection>>
+ core::marker::Send
+ 'async_trait,
>,
>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{
Box::pin(async {
let raw = parts.headers.remove(Self::KEY).ok_or(Error::NotLoggedIn)?;
let (account, token) = raw
.to_str()?
.split_once(':')
.ok_or(Error::InvalidAuthHeader)?;
Ok(Self {
account: account.parse().map_err(|_| Error::InvalidAuthHeader)?,
token: token.to_owned(),
})
})
}
}
Expand Down

0 comments on commit 7ad3d6c

Please sign in to comment.