diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-03-20 20:23:06 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-03-20 20:24:44 +0100 |
commit | 9c3a341e79581541fc39ceddeec28daae7dc28cf (patch) | |
tree | a283c57d8917fcfd9fbed06c730b64b8c79e4504 /src | |
parent | cd6eba8b2b70404e93d9d4b0832faa7c9f00d217 (diff) | |
download | ramaskrik-social-9c3a341e79581541fc39ceddeec28daae7dc28cf.tar.gz ramaskrik-social-9c3a341e79581541fc39ceddeec28daae7dc28cf.tar.bz2 ramaskrik-social-9c3a341e79581541fc39ceddeec28daae7dc28cf.zip |
Pass database url into build_rocket helper function.
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(()) } |