-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anthony M. Bonafide <AnthonyMBonafide@gmail.com>
- Loading branch information
1 parent
9f43209
commit 46a65a8
Showing
9 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DATABASE_URL="postgres://postgres:password@127.0.0.1:5432/newsletter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
#[derive(serde::Deserialize)] | ||
pub struct Settings{ | ||
pub database: DatabaseSettings, | ||
pub struct Settings { | ||
pub database: DatabaseSettings, | ||
pub application_port: u16, | ||
} | ||
|
||
#[derive(serde::Deserialize)] | ||
pub struct DatabaseSettings{ | ||
pub struct DatabaseSettings { | ||
pub username: String, | ||
pub password:String, | ||
pub password: String, | ||
pub port: u16, | ||
pub host: String, | ||
pub database_name:String, | ||
pub database_name: String, | ||
} | ||
|
||
impl DatabaseSettings { | ||
pub fn connection_string(&self) -> String { | ||
format!("postgres://{}:{}@{}:{}/{}", self.username, self.password, self.host, self.password, self.database_name) | ||
pub fn connection_string(&self) -> String { | ||
format!( | ||
"postgres://{}:{}@{}:{}/{}", | ||
self.username, self.password, self.host, self.port, self.database_name | ||
) | ||
} | ||
} | ||
|
||
|
||
pub fn get_configuration() -> Result<Settings, config::ConfigError>{ | ||
pub fn get_configuration() -> Result<Settings, config::ConfigError> { | ||
let settings = config::Config::builder() | ||
.add_source(config::File::new("configuration.yaml", config::FileFormat::Yaml)) | ||
.build()?; | ||
.add_source(config::File::new( | ||
"configuration.yaml", | ||
config::FileFormat::Yaml, | ||
)) | ||
.build()?; | ||
|
||
settings.try_deserialize() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
use actix_web::HttpResponse; | ||
|
||
pub async fn health_check() -> HttpResponse { | ||
HttpResponse::Ok().finish() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
|
||
mod health_check; | ||
mod subscriptions; | ||
|
||
pub use health_check::*; | ||
pub use subscriptions::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters