aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-01-11 23:17:19 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-01-11 23:17:19 +0100
commit49a06ccbf087c4ed0db3d61f3ac4892f45858ce1 (patch)
tree2173e4da34f793194c3f703160d981326681fc7b /src/utils
parent0a7015b2b1d1e6682385ff3c02f14c1911158a8e (diff)
downloadrocket-blog-49a06ccbf087c4ed0db3d61f3ac4892f45858ce1.tar.gz
rocket-blog-49a06ccbf087c4ed0db3d61f3ac4892f45858ce1.tar.bz2
rocket-blog-49a06ccbf087c4ed0db3d61f3ac4892f45858ce1.zip
Read .env file in main.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs9
1 files changed, 1 insertions, 8 deletions
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<ConnectionManager<PgConnection>>;
/// 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::<PgConnection>::new(dburl);
r2d2::Pool::new(config, manager).expect("db pool")
}