1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
pub mod config; pub mod error; pub mod model; pub mod module; pub mod service; pub mod utils; pub mod web; use crate::error::LightSpeedError; use crate::service::auth::InMemoryRolesProvider; use log::info; #[derive(Clone)] pub struct CoreModule { pub auth: service::auth::AuthService<InMemoryRolesProvider>, pub jwt: service::jwt::JwtService, } impl CoreModule { pub fn new(config: config::CoreConfig) -> Result<CoreModule, LightSpeedError> { println!("Creating CoreModule"); info!("Creating CoreModule"); let jwt = service::jwt::JwtService::new(&config.jwt)?; let auth = service::auth::AuthService::new(InMemoryRolesProvider::new(vec![])); Ok(CoreModule { jwt, auth }) } } #[async_trait::async_trait(?Send)] impl module::Module for CoreModule { async fn start(&mut self) -> Result<(), LightSpeedError> { info!("Starting CoreModule"); Ok(()) } }