From a14dbf5cd253df50c69b03a1b83f4a7ee9cb990f Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Mon, 3 Apr 2023 18:58:36 -0500 Subject: [PATCH] Use env variable for opening database --- actix/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/actix/src/main.rs b/actix/src/main.rs index ebf5c8c..9fc2b09 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -22,10 +22,8 @@ struct AppState { async fn add_link(req: String, data: web::Data) -> HttpResponse { let out = utils::add_link(req, &data.db); if out.0 { - println!("ok{}", out.1); HttpResponse::Ok().body(out.1) } else { - println!("bad{}", out.1); HttpResponse::BadRequest().body(out.1) } } @@ -74,7 +72,7 @@ async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .app_data(web::Data::new(AppState { - db: database::open_db("./urls.sqlite".to_string()), + db: database::open_db(env::var("db_url").unwrap_or("./urls.sqlite".to_string())), })) .service(link_handler) .service(error404)