use domain vector instead of single string
This commit is contained in:
parent
c5f2f49c16
commit
0b1ada9221
1 changed files with 3 additions and 3 deletions
|
@ -53,7 +53,7 @@ impl Display for Protocol {
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
struct DomainLinkConfig {
|
struct DomainLinkConfig {
|
||||||
domain: String,
|
domains: Vec<String>,
|
||||||
protocol: Protocol,
|
protocol: Protocol,
|
||||||
target: String,
|
target: String,
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ async fn handle(redirects: web::Data<Vec<DomainLinkConfig>>, request: HttpReques
|
||||||
let host = host_raw.to_str().expect("host conversion to string should never fail");
|
let host = host_raw.to_str().expect("host conversion to string should never fail");
|
||||||
println!("{host}");
|
println!("{host}");
|
||||||
for redirect in redirects.iter() {
|
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();
|
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<Vec<DomainLinkConfig>>, request: HttpRe
|
||||||
let host = host_raw.to_str().expect("host conversion to string should never fail");
|
let host = host_raw.to_str().expect("host conversion to string should never fail");
|
||||||
println!("{host}");
|
println!("{host}");
|
||||||
for redirect in redirects.iter() {
|
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);
|
let body = format!("Redirecting: {} -> {}{}", host, redirect.protocol, redirect.target);
|
||||||
return HttpResponse::Ok().body(body);
|
return HttpResponse::Ok().body(body);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue