From 49a06ccbf087c4ed0db3d61f3ac4892f45858ce1 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 11 Jan 2018 23:17:19 +0100 Subject: Read .env file in main. --- src/utils/mod.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/utils') diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 1d697fe..a1ece8b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,20 +1,13 @@ use diesel::pg::PgConnection; use r2d2; use r2d2_diesel::ConnectionManager; -use dotenv::dotenv; -use std::env; // An alias to the type for a pool of Diesel PostgreSql connections. type Pool = r2d2::Pool>; /// Initializes a database pool. -pub fn init_db_pool() -> Pool { - dotenv().ok(); - +pub fn init_db_pool<'a>(dburl: &'a str) -> Pool { let config = r2d2::Config::default(); - let dburl = env::var("DATABASE_URL") - .expect("DATABASE_URL environment variable must be set"); - let manager = ConnectionManager::::new(dburl); r2d2::Pool::new(config, manager).expect("db pool") } -- cgit v1.2.3