From 96ac29c7c152154b9528c1328d2527b3c79492e9 Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:37:55 +0100 Subject: [PATCH] fix issue with toml configuration missing url value --- Cargo.lock | 2 +- Cargo.toml | 2 +- example-config.toml | 1 + src/config.rs | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a2d9c3..bc1a80c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -532,7 +532,7 @@ dependencies = [ [[package]] name = "defguard-proxy" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index bd5a50d..e6a5db9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "defguard-proxy" -version = "1.1.0" +version = "1.1.1" edition = "2021" license = "Apache-2.0" homepage = "https://github.com/DefGuard/proxy" diff --git a/example-config.toml b/example-config.toml index 025d18d..b6dc4d3 100644 --- a/example-config.toml +++ b/example-config.toml @@ -16,3 +16,4 @@ grpc_port = 50051 log_level = "info" rate_limit_per_second = 0 rate_limit_burst = 0 +url = "http://localhost:8080" diff --git a/src/config.rs b/src/config.rs index b1dcd5e..4c64429 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,10 @@ use log::LevelFilter; use serde::Deserialize; use url::Url; +fn default_url() -> Url { + Url::parse("http://localhost:8080").unwrap() +} + #[derive(Parser, Debug, Deserialize)] #[command(version)] pub struct Config { @@ -42,6 +46,7 @@ pub struct Config { value_parser = Url::parse, default_value = "http://localhost:8080" )] + #[serde(default = "default_url")] pub url: Url, /// Configuration file path