diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 5 | ||||
-rw-r--r-- | src/main.rs | 5 |
2 files changed, 5 insertions, 5 deletions
@@ -26,10 +26,7 @@ use std::collections::HashMap; use std::error::Error; use std::result::Result; -pub fn build_rocket() -> Result<rocket::Rocket, Box<dyn Error>> { - let db_url = dotenv::var("DATABASE_URL") - .map_err(|_| "No database! Set DATABASE_URL env var and try again.")?; - +pub fn build_rocket(db_url: &str) -> Result<rocket::Rocket, Box<dyn Error>> { let mut db_config = HashMap::new(); db_config.insert("url", rocket::config::Value::from(db_url)); diff --git a/src/main.rs b/src/main.rs index fdc8ff3..773fc66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,9 @@ use std::error::Error; use std::result::Result; fn main() -> Result<(), Box<dyn Error>> { - ramaskrik::build_rocket()?.launch(); + let db_url = dotenv::var("DATABASE_URL") + .map_err(|_| "No database! Set DATABASE_URL env var and try again.")?; + + ramaskrik::build_rocket(&db_url)?.launch(); Ok(()) } |