mirror of
https://github.com/MedzikUser/HomeDisk.git
synced 2024-08-14 21:46:53 +00:00
33 lines
801 B
Rust
33 lines
801 B
Rust
mod init;
|
|
|
|
use homedisk_database::Database;
|
|
use homedisk_types::config::types::Config;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
init::init();
|
|
|
|
let config = Config::parse().expect("parse configuration file");
|
|
|
|
let db = Database::open("homedisk.db")
|
|
.await
|
|
.expect("open SQLite database");
|
|
|
|
// change the type from Vec<String> to Vec<HeaderValue> so that the http server can correctly detect CORS hosts
|
|
let origins = config
|
|
.http
|
|
.cors
|
|
.iter()
|
|
.map(|e| e.parse().expect("parse CORS host"))
|
|
.collect();
|
|
|
|
let host = format!(
|
|
"{host}:{port}",
|
|
host = config.http.host,
|
|
port = config.http.port
|
|
);
|
|
|
|
homedisk_server::serve(host, origins, db, config)
|
|
.await
|
|
.expect("start http server");
|
|
}
|