Añade carga de ajustes de configuración globales
This commit is contained in:
parent
4e23523e80
commit
96884cbbc0
12 changed files with 146 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::server;
|
||||
|
||||
/// Modules must implement this trait.
|
||||
/// Los módulos deben implementar este *trait*.
|
||||
pub trait Module: Send + Sync {
|
||||
fn name(&self) -> String;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,21 @@
|
|||
use crate::config::SETTINGS;
|
||||
use crate::core::{Server, all, server};
|
||||
|
||||
pub fn run(bootstrap: Option<fn()>) -> Result<Server, std::io::Error> {
|
||||
// Call application bootstrap.
|
||||
// Ejecuta la función de inicio específica para la aplicación.
|
||||
if bootstrap != None {
|
||||
let _ = &(bootstrap.unwrap())();
|
||||
}
|
||||
|
||||
// Inicializa el servidor web.
|
||||
let server = server::HttpServer::new(|| {
|
||||
server::App::new()
|
||||
.configure(&all::modules)
|
||||
})
|
||||
.bind("127.0.0.1:8000")?
|
||||
.bind(format!("{}:{}",
|
||||
&SETTINGS.webserver.bind_address,
|
||||
&SETTINGS.webserver.bind_port
|
||||
))?
|
||||
.run();
|
||||
Ok(server)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::core::module::Module;
|
|||
use std::sync::RwLock;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Registered modules.
|
||||
// Módulos registrados.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
pub static MODULES: Lazy<RwLock<Vec<&dyn Module>>> = Lazy::new(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue