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); }