Skip to content

Commit

Permalink
Merge pull request #53 from LRZ-BADW/dependabot/cargo/secrecy-0.10.0
Browse files Browse the repository at this point in the history
chore(cargo): update: Bump secrecy from 0.8.0 to 0.10.0
  • Loading branch information
gierens authored Sep 18, 2024
2 parents c6cbfba + e84adcc commit 92525e8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ updates:
schedule:
interval: "daily"
commit-message:
prefix: "chore(cargo): update"
prefix: "chore(cargo)"
labels: []

- package-ecosystem: "github-actions"
Expand All @@ -15,5 +15,5 @@ updates:
schedule:
interval: "daily"
commit-message:
prefix: "chore(ci): update"
prefix: "chore(ci)"
labels: []
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-log = "0.2"
tracing-actix-web = "0.7"
secrecy = { version = "0.8", features = ["serde"] }
secrecy = { version = "0.10.1", features = ["serde"] }
anyhow = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
Expand Down
16 changes: 14 additions & 2 deletions api/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use secrecy::{ExposeSecret, Secret};
use secrecy::{ExposeSecret, SecretString};
use serde::Deserialize;
use serde_aux::field_attributes::deserialize_number_from_string;
use sqlx::mysql::{MySqlConnectOptions, MySqlSslMode};

Expand All @@ -17,10 +18,21 @@ pub struct ApplicationSettings {
pub base_url: String,
}

fn deserialize_secret_string<'de, D>(
deserializer: D,
) -> Result<SecretString, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(SecretString::from(s))
}

#[derive(Clone, serde::Deserialize)]
pub struct DatabaseSettings {
pub username: String,
pub password: Secret<String>,
#[serde(deserialize_with = "deserialize_secret_string")]
pub password: SecretString,
#[serde(deserialize_with = "deserialize_number_from_string")]
pub port: u16,
pub host: String,
Expand Down
2 changes: 1 addition & 1 deletion api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async fn main() -> anyhow::Result<()> {

let configuration =
get_configuration().expect("Failed to read configuration.");
let application = Application::build(configuration.clone()).await?;
let application = Application::build(configuration).await?;
application.run_until_stopped().await?;

Ok(())
Expand Down

0 comments on commit 92525e8

Please sign in to comment.