21 lines
467 B
Rust
21 lines
467 B
Rust
use std::sync::Arc;
|
|
|
|
use async_trait::async_trait;
|
|
use axum::{extract::FromRequestParts, http::request::Parts};
|
|
|
|
use crate::{database::Database, state::AppState};
|
|
|
|
use super::error::ApiError;
|
|
|
|
#[async_trait]
|
|
impl FromRequestParts<Arc<AppState>> for Database {
|
|
type Rejection = ApiError<'static>;
|
|
|
|
async fn from_request_parts(
|
|
_parts: &mut Parts,
|
|
state: &Arc<AppState>,
|
|
) -> Result<Self, Self::Rejection> {
|
|
Ok(state.into())
|
|
}
|
|
}
|