|
|
|
mod action;
|
|
|
|
mod client;
|
|
|
|
mod form_data;
|
|
|
|
mod line;
|
|
|
|
mod options;
|
|
|
|
mod routes;
|
|
|
|
mod wot_log;
|
|
|
|
|
|
|
|
use actix_files::Files;
|
|
|
|
use actix_web::{middleware, web, App, HttpServer};
|
|
|
|
|
|
|
|
use handlebars::Handlebars;
|
|
|
|
use log::info;
|
|
|
|
|
|
|
|
use action::Action;
|
|
|
|
use client::Client;
|
|
|
|
use form_data::FormData;
|
|
|
|
use options::Options;
|
|
|
|
use wot_log::WotLog;
|
|
|
|
|
|
|
|
pub fn default_false() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_web::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
// parse command line arguments
|
|
|
|
let options = Options::init();
|
|
|
|
|
|
|
|
// start logger
|
|
|
|
rag::init().unwrap();
|
|
|
|
|
|
|
|
// load templates
|
|
|
|
let mut handlebars = Handlebars::new();
|
|
|
|
handlebars.register_templates_directory(".html", "./templates").unwrap();
|
|
|
|
let handlebars_ref = web::Data::new(handlebars);
|
|
|
|
|
|
|
|
info!("Configuration (see --help to change):");
|
|
|
|
info!("{:?}", options);
|
|
|
|
|
|
|
|
// setup and start http server
|
|
|
|
HttpServer::new(move || {
|
|
|
|
App::new()
|
|
|
|
.app_data(handlebars_ref.clone())
|
|
|
|
.wrap(middleware::Logger::default())
|
|
|
|
.service(routes::help::get)
|
|
|
|
.service(routes::index::get)
|
|
|
|
.service(routes::submit::get)
|
|
|
|
.service(routes::submit::post)
|
|
|
|
.service(Files::new("/static", "static").show_files_listing())
|
|
|
|
})
|
|
|
|
.bind((options.address, options.port))?
|
|
|
|
.workers(options.workers)
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|