Añade carga de ajustes de configuración globales

This commit is contained in:
Manuel Cillero 2022-02-12 10:14:36 +01:00
parent 4e23523e80
commit 96884cbbc0
12 changed files with 146 additions and 12 deletions

View file

@ -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)
}