18 lines
443 B
Rust
18 lines
443 B
Rust
use axum::{async_trait, extract::FromRequestParts};
|
|
use http::request::Parts;
|
|
|
|
use crate::{context::Context, model::response::ResErr};
|
|
|
|
|
|
#[async_trait]
|
|
impl<S> FromRequestParts<S> for Context
|
|
where
|
|
S: Send + Sync,
|
|
{
|
|
type Rejection = ResErr;
|
|
|
|
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
|
|
let context: &Context = parts.extensions.get().unwrap();
|
|
Ok(context.clone())
|
|
}
|
|
} |