feat: use url format
This commit is contained in:
parent
b9c7bda2b1
commit
746949f0e5
1 changed files with 18 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::postgres::PgConnectOptions;
|
|
||||||
use tokio::fs::read_to_string;
|
use tokio::fs::read_to_string;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
@ -81,13 +80,24 @@ pub struct Web {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Database {
|
impl Database {
|
||||||
pub fn connect_options(&self) -> PgConnectOptions {
|
pub fn url(&self) -> String {
|
||||||
PgConnectOptions::new()
|
let mut url = String::from("postgres://");
|
||||||
.database(&self.database)
|
|
||||||
.host(&self.host)
|
url += &self.username;
|
||||||
.username(&self.username)
|
|
||||||
.password(&self.password)
|
url += ":";
|
||||||
.port(self.port)
|
url += &self.password;
|
||||||
|
|
||||||
|
url += "@";
|
||||||
|
|
||||||
|
url += &self.host;
|
||||||
|
url += ":";
|
||||||
|
url += &self.port.to_string();
|
||||||
|
|
||||||
|
url += "/";
|
||||||
|
url += &self.database;
|
||||||
|
|
||||||
|
url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue