Skip to content

Commit 2ac9cb0

Browse files
authored
Fix compilation hopefully, style improvements
1 parent 35ba5e6 commit 2ac9cb0

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

Diff for: server/svix-server/src/cfg.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,33 @@ fn default_redis_pending_duration_secs() -> u64 {
7676
45
7777
}
7878

79-
fn validate_operational_webhook_url(url: &Option<String>) -> Result<(), ValidationError> {
80-
if let Some(url_str) = url {
81-
match Url::parse(url_str) {
82-
Ok(url) => {
83-
// Verify scheme is http or https
84-
if url.scheme() != "http" && url.scheme() != "https" {
85-
return Err(validation_error(
86-
Some("operational_webhook_address"),
87-
Some("URL scheme must be http or https"),
88-
));
89-
}
90-
91-
// Verify there's a host
92-
if url.host().is_none() {
93-
return Err(validation_error(
94-
Some("operational_webhook_address"),
95-
Some("URL must include a valid host"),
96-
));
97-
}
79+
fn validate_operational_webhook_url(url: &str) -> Result<(), ValidationError> {
80+
match Url::parse(url) {
81+
Ok(url) => {
82+
// Verify scheme is http or https
83+
if url.scheme() != "http" && url.scheme() != "https" {
84+
return Err(validation_error(
85+
Some("operational_webhook_address"),
86+
Some("URL scheme must be http or https"),
87+
));
9888
}
99-
Err(_) => {
89+
90+
// Verify there's a host
91+
if url.host().is_none() {
10092
return Err(validation_error(
10193
Some("operational_webhook_address"),
102-
Some("Invalid URL format"),
94+
Some("URL must include a valid host"),
10395
));
10496
}
10597
}
98+
Err(_) => {
99+
return Err(validation_error(
100+
Some("operational_webhook_address"),
101+
Some("Invalid URL format"),
102+
));
103+
}
106104
}
105+
107106
Ok(())
108107
}
109108

Diff for: server/svix-server/src/core/operational_webhooks.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,14 @@ pub struct OperationalWebhookSenderInner {
115115
}
116116

117117
impl OperationalWebhookSenderInner {
118-
pub fn new(keys: Arc<JwtSigningConfig>, url: Option<String>) -> Arc<Self> {
118+
pub fn new(keys: Arc<JwtSigningConfig>, mut url: Option<String>) -> Arc<Self> {
119119
// Sanitize the URL if present
120-
let sanitized_url = url.as_ref().map(|url_str| {
120+
if let Some(url) = &mut url {
121121
// Remove trailing slashes
122-
let mut cleaned_url = url_str.to_string();
123122
while cleaned_url.ends_with('/') {
124123
cleaned_url.pop();
125124
}
126-
cleaned_url
127-
});
125+
}
128126

129127
Arc::new(Self {
130128
signing_config: keys,

0 commit comments

Comments
 (0)