Replace DB_URL with DATABASE_URL

This way it is shared with diesel, which simplifies a lot the setup

Also fixes a few issues in the documentation, that are not directly related
This commit is contained in:
Bat
2018-10-06 19:17:36 +01:00
parent 7a64005ca9
commit 9cc795d8be
8 changed files with 47 additions and 43 deletions
+10 -3
View File
@@ -191,12 +191,19 @@ lazy_static! {
pub static ref BASE_URL: String = env::var("BASE_URL")
.unwrap_or(format!("127.0.0.1:{}", env::var("ROCKET_PORT").unwrap_or(String::from("8000"))));
pub static ref DB_URL: String = env::var("DB_URL")
.unwrap_or(format!("postgres://plume:plume@localhost/{}", env::var("DB_NAME").unwrap_or(String::from("plume"))));
pub static ref USE_HTTPS: bool = env::var("USE_HTTPS").map(|val| val == "1").unwrap_or(true);
}
#[cfg(all(feature = "postgres", not(feature = "sqlite")))]
lazy_static! {
pub static ref DATABASE_URL: String = env::var("DATABASE_URL").unwrap_or(String::from("postgres://plume:plume@localhost/plume"));
}
#[cfg(all(feature = "sqlite", not(feature = "postgres")))]
lazy_static! {
pub static ref DATABASE_URL: String = env::var("DATABASE_URL").unwrap_or(String::from("plume.sqlite"));
}
pub fn ap_url(url: String) -> String {
let scheme = if *USE_HTTPS {
"https"