diff options
Diffstat (limited to 'src/frontend/onboarding.rs')
-rw-r--r-- | src/frontend/onboarding.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/frontend/onboarding.rs b/src/frontend/onboarding.rs index faf8cdd..9f3f36b 100644 --- a/src/frontend/onboarding.rs +++ b/src/frontend/onboarding.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use crate::database::{settings, Storage}; use axum::{ - extract::{Extension, Host}, + extract::{FromRef, Host, State}, http::StatusCode, response::{Html, IntoResponse}, Json, @@ -131,10 +131,10 @@ async fn onboard<D: Storage + 'static>( } pub async fn post<D: Storage + 'static>( - Extension(db): Extension<D>, + State(db): State<D>, Host(host): Host, - Extension(http): Extension<reqwest::Client>, - Extension(jobset): Extension<Arc<Mutex<JoinSet<()>>>>, + State(http): State<reqwest::Client>, + State(jobset): State<Arc<Mutex<JoinSet<()>>>>, Json(data): Json<OnboardingData>, ) -> axum::response::Response { let user_uid = format!("https://{}/", host.as_str()); @@ -168,14 +168,13 @@ pub async fn post<D: Storage + 'static>( } } -pub fn router<S: Storage + 'static>( - database: S, - http: reqwest::Client, - jobset: Arc<Mutex<JoinSet<()>>>, -) -> axum::routing::MethodRouter { +pub fn router<St, S>() -> axum::routing::MethodRouter<St> +where + S: Storage + FromRef<St> + 'static, + Arc<Mutex<JoinSet<()>>>: FromRef<St>, + reqwest::Client: FromRef<St>, + St: Clone + Send + Sync + 'static, +{ axum::routing::get(get) .post(post::<S>) - .layer::<_, _, std::convert::Infallible>(axum::Extension(database)) - .layer::<_, _, std::convert::Infallible>(axum::Extension(http)) - .layer(axum::Extension(jobset)) } |