From 63636d00ca56ee37f9cb9db3fece81d615e21a1a Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Mon, 26 Nov 2018 12:33:37 +0100 Subject: Refactor html views --- src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2d5218f..a025e69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ use futures::{Future, Stream}; use tokio_threadpool::Builder; use tokio_executor::enter; -mod auth_handler; +mod request_handler; mod cookie_store; mod http_server; mod router; @@ -49,6 +49,7 @@ use cookie_store::CookieStore; pub struct ApplicationState { cookie_store: CookieStore, cookie_max_age: Duration, + debug: bool, } #[derive(Debug, StructOpt)] @@ -64,8 +65,14 @@ fn main() { let opt = Opt::from_args(); simple_logger::init_with_level(if opt.debug { Debug } else { Warn }) .unwrap_or_else(|_| panic!("Failed to initialize logger")); + debug!("If you read this message then we're running debug (-d) mode."); + debug!("Debug mode is not safe for public accesible instances"); - let state = ApplicationState { cookie_store: CookieStore::new(), cookie_max_age: Duration::days(1) }; + let state = ApplicationState { + cookie_store: CookieStore::new(), + cookie_max_age: Duration::days(1), + debug: opt.debug, + }; let server_shutdown_condvar = Arc::new(atomic::AtomicBool::new(false)); @@ -82,7 +89,7 @@ fn main() { }) }; - let auth_handler = auth_handler::AuthHandler::make(); + let request_handler = request_handler::RequestHandler::make(); let runtime = Builder::new() .name_prefix("httpd-") .after_start(|| { @@ -91,7 +98,7 @@ fn main() { }) .build(); - let program = http_server::serve(opt.addr, state, auth_handler); + let program = http_server::serve(opt.addr, state, request_handler); runtime.spawn(program); let ctrl_c_block = tokio_signal::ctrl_c() -- cgit v1.2.1