i broke everything oh no
This commit is contained in:
parent
26de7b3cc4
commit
2843aec125
8 changed files with 170 additions and 216 deletions
15
src/state.rs
15
src/state.rs
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue