2023-12-22 21:26:50 +00:00
|
|
|
mod api;
|
|
|
|
mod cli;
|
|
|
|
mod file_util;
|
|
|
|
|
|
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
let args = cli::Cli::get();
|
|
|
|
println!("cli: {:?}", args);
|
|
|
|
|
|
|
|
simplelog::WriteLogger::init(
|
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
{
|
|
|
|
log::LevelFilter::Debug
|
|
|
|
},
|
|
|
|
#[cfg(not(debug_assertions))]
|
|
|
|
{
|
|
|
|
log::LevelFilter::Info
|
|
|
|
},
|
|
|
|
Default::default(),
|
|
|
|
std::fs::File::create(&args.log).expect("Failed to create log file"),
|
|
|
|
//std::fs::File::create("/home/deck/powertools-rs.log").unwrap(),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
log::debug!("Logging to: {}", args.log.display());
|
|
|
|
|
2024-01-06 18:26:35 +00:00
|
|
|
// setup
|
|
|
|
log::debug!("Building folder layout (if not exists) at: {}", &args.folder.display());
|
|
|
|
file_util::build_folder_layout(&args.folder)?;
|
|
|
|
|
2023-12-22 21:26:50 +00:00
|
|
|
let leaked_args: &'static cli::Cli = Box::leak::<'static>(Box::new(args));
|
|
|
|
HttpServer::new(move || {
|
|
|
|
App::new()
|
|
|
|
.app_data(web::Data::new(leaked_args))
|
|
|
|
//.app_data(web::Data::new(IndexPage::load("dist/index.html").unwrap()))
|
|
|
|
//.app_data(basic::Config::default().realm("Restricted area"))
|
|
|
|
.service(api::get_setting_by_id)
|
2024-01-06 18:26:35 +00:00
|
|
|
.service(api::get_setting_by_steam_app_id)
|
2023-12-22 21:26:50 +00:00
|
|
|
.service(api::save_setting_with_new_id)
|
|
|
|
})
|
|
|
|
.bind(("0.0.0.0", leaked_args.port))?
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|