From 0b1ada922170df71c48782e94fcfc64539d607bb Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 8 Apr 2024 23:05:25 +0200 Subject: [PATCH] use domain vector instead of single string --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index dc3266c..1e10df3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ impl Display for Protocol { #[derive(Clone, Serialize, Deserialize)] struct DomainLinkConfig { - domain: String, + domains: Vec, protocol: Protocol, target: String, } @@ -195,7 +195,7 @@ async fn handle(redirects: web::Data>, request: HttpReques let host = host_raw.to_str().expect("host conversion to string should never fail"); println!("{host}"); for redirect in redirects.iter() { - if redirect.domain == host { + if redirect.domains.contains(&host.to_owned()) { return HttpResponse::PermanentRedirect().insert_header(("location", format!("{}{}", redirect.protocol, redirect.target).as_str())).finish(); } } @@ -211,7 +211,7 @@ async fn dry_handle(redirects: web::Data>, request: HttpRe let host = host_raw.to_str().expect("host conversion to string should never fail"); println!("{host}"); for redirect in redirects.iter() { - if redirect.domain == host { + if redirect.domains.contains(&host.to_owned()) { let body = format!("Redirecting: {} -> {}{}", host, redirect.protocol, redirect.target); return HttpResponse::Ok().body(body); }