mirror of https://github.com/raftario/filite.git
Add config to webserver data
This commit is contained in:
parent
9a0c5f2583
commit
4653c60f31
|
@ -52,13 +52,16 @@ fn main() {
|
|||
|
||||
let pool = setup::create_pool(&config.database_url, config.pool_size);
|
||||
|
||||
let port = config.port;
|
||||
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.data(config.clone())
|
||||
.data(pool.clone())
|
||||
.wrap(middleware::Logger::default())
|
||||
.route("/", web::get().to(index))
|
||||
})
|
||||
.bind(&format!("localhost:{}", config.port))
|
||||
.bind(&format!("localhost:{}", port))
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("Can't bind webserver to specified port: {}.", e);
|
||||
process::exit(1);
|
||||
|
|
|
@ -28,7 +28,7 @@ fn get_config_path() -> PathBuf {
|
|||
}
|
||||
|
||||
/// Application configuration
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
/// Port to listen on
|
||||
|
|
Loading…
Reference in New Issue