Refactor AppState and update database connection handling; integrate SettingsService
This commit is contained in:
@@ -3,20 +3,22 @@ use std::sync::Arc;
|
||||
use axum::{Extension, Router};
|
||||
use migration::sea_orm::DatabaseConnection;
|
||||
|
||||
use crate::middlewares;
|
||||
use crate::{middlewares, services::settings::SettingsStore};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
// TODO: remove dead_code allowances when fields are used
|
||||
#[allow(dead_code)]
|
||||
pub database_connection: DatabaseConnection,
|
||||
pub database_connection: Arc<DatabaseConnection>,
|
||||
// TODO: remove dead_code allowances when fields are used
|
||||
#[allow(dead_code)]
|
||||
pub service: Arc<AppService>,
|
||||
}
|
||||
|
||||
pub type ServiceState<T: ?Sized + Send + Sync> = Arc<T>;
|
||||
|
||||
pub struct AppService {
|
||||
//
|
||||
pub settings: ServiceState<dyn SettingsStore>,
|
||||
}
|
||||
|
||||
pub fn get_root_router(state: impl Into<Arc<AppState>>) -> Router {
|
||||
|
||||
Reference in New Issue
Block a user