mirror of
https://github.com/mastodon/flodgatt
synced 2025-04-11 22:58:25 +02:00
Fix DATABASE_URL
parsing (#122)
This commit is contained in:
parent
19792d9484
commit
6a6537253d
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -440,7 +440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flodgatt"
|
name = "flodgatt"
|
||||||
version = "0.6.7"
|
version = "0.6.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dotenv 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dotenv 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -460,6 +460,7 @@ dependencies = [
|
|||||||
"strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"warp 0.1.20 (git+https://github.com/seanmonstar/warp.git)",
|
"warp 0.1.20 (git+https://github.com/seanmonstar/warp.git)",
|
||||||
]
|
]
|
||||||
|
@ -24,6 +24,7 @@ strum_macros = "0.16.0"
|
|||||||
r2d2_postgres = "0.16.0"
|
r2d2_postgres = "0.16.0"
|
||||||
r2d2 = "0.8.8"
|
r2d2 = "0.8.8"
|
||||||
lru = "0.4.3"
|
lru = "0.4.3"
|
||||||
|
urlencoding = "1.0.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use super::{postgres_cfg_types::*, EnvVar};
|
use super::{postgres_cfg_types::*, EnvVar};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use urlencoding;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PostgresConfig {
|
pub struct PostgresConfig {
|
||||||
@ -32,6 +33,12 @@ impl EnvVar {
|
|||||||
|
|
||||||
self.maybe_add_env_var("DB_PORT", url.port());
|
self.maybe_add_env_var("DB_PORT", url.port());
|
||||||
self.maybe_add_env_var("DB_PASS", url.password());
|
self.maybe_add_env_var("DB_PASS", url.password());
|
||||||
|
self.maybe_add_env_var(
|
||||||
|
"DB_HOST",
|
||||||
|
url.host().map(|h| {
|
||||||
|
urlencoding::decode(&h.to_string()).expect("Non-Unicode text in hostname")
|
||||||
|
}),
|
||||||
|
);
|
||||||
self.maybe_add_env_var("DB_USER", none_if_empty(url.username().to_string()));
|
self.maybe_add_env_var("DB_USER", none_if_empty(url.username().to_string()));
|
||||||
self.maybe_add_env_var("DB_NAME", none_if_empty(url.path()[1..].to_string()));
|
self.maybe_add_env_var("DB_NAME", none_if_empty(url.path()[1..].to_string()));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user