From 7308121fa3efc785bf964b8ab32505ba25513fdc Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 24 Aug 2020 13:33:06 +0530 Subject: add cli opts --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 35e686e..5cd3492 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,14 +11,18 @@ use db::{init_db, open_connection}; mod service; use service::shortner_service; +mod cli; +use cli::CONFIG; + fn main() -> Result<()> { pretty_env_logger::init(); - init_db("./urls.db_3")?; + + init_db(&CONFIG.db_path)?; smol::run(async { - let addr = ([127, 0, 0, 1], 3000).into(); - let service = make_service_fn(move |_| async { + let addr = ([127, 0, 0, 1], CONFIG.port).into(); + let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(move |req| { - let db_conn = open_connection("./urls.db_3").unwrap(); + let db_conn = open_connection(&CONFIG.db_path).unwrap(); shortner_service(req, db_conn) })) }); -- cgit v1.2.3