i broke everything oh no

This commit is contained in:
sam 2023-10-19 17:24:08 +02:00
parent 26de7b3cc4
commit 2843aec125
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
8 changed files with 170 additions and 216 deletions

View file

@ -1,6 +1,21 @@
use axum::{extract::{FromRef, FromRequestParts}, async_trait, http::request::Parts};
use sqlx::{postgres::Postgres, Pool};
#[derive(Clone, FromRef)]
pub struct AppState {
pub pool: Pool<Postgres>,
pub hbs: handlebars::Handlebars<'static>,
}
#[async_trait]
impl<S> FromRequestParts<S> for AppState
where
Self: FromRef<S>,
S: Send + Sync,
{
type Rejection = &'static str;
async fn from_request_parts(_parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
Ok(Self::from_ref(state))
}
}