aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 8 insertions, 4 deletions
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};
11mod service; 11mod service;
12use service::shortner_service; 12use service::shortner_service;
13 13
14mod cli;
15use cli::CONFIG;
16
14fn main() -> Result<()> { 17fn main() -> Result<()> {
15 pretty_env_logger::init(); 18 pretty_env_logger::init();
16 init_db("./urls.db_3")?; 19
20 init_db(&CONFIG.db_path)?;
17 smol::run(async { 21 smol::run(async {
18 let addr = ([127, 0, 0, 1], 3000).into(); 22 let addr = ([127, 0, 0, 1], CONFIG.port).into();
19 let service = make_service_fn(move |_| async { 23 let service = make_service_fn(|_| async {
20 Ok::<_, hyper::Error>(service_fn(move |req| { 24 Ok::<_, hyper::Error>(service_fn(move |req| {
21 let db_conn = open_connection("./urls.db_3").unwrap(); 25 let db_conn = open_connection(&CONFIG.db_path).unwrap();
22 shortner_service(req, db_conn) 26 shortner_service(req, db_conn)
23 })) 27 }))
24 }); 28 });