From 8e077609e9eff24fd9d4b9d9e253a147fef9bb9e Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 8 Apr 2024 23:05:33 +0200 Subject: [PATCH] remove protocol settings --- src/main.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1e10df3..7a30947 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,25 +36,9 @@ macro_rules! error { }; } -#[derive(Clone, Serialize, Deserialize)] -enum Protocol { - Http, - Https -} - -impl Display for Protocol { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Protocol::Http => write!(f, "http://"), - Protocol::Https => write!(f, "https://") - } - } -} - #[derive(Clone, Serialize, Deserialize)] struct DomainLinkConfig { domains: Vec, - protocol: Protocol, target: String, } @@ -196,7 +180,7 @@ async fn handle(redirects: web::Data>, request: HttpReques println!("{host}"); for redirect in redirects.iter() { 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", redirect.target.to_string().as_str())).finish(); } } let fail_msg = format!("No Redirect for {host} found"); @@ -212,7 +196,7 @@ async fn dry_handle(redirects: web::Data>, request: HttpRe println!("{host}"); for redirect in redirects.iter() { if redirect.domains.contains(&host.to_owned()) { - let body = format!("Redirecting: {} -> {}{}", host, redirect.protocol, redirect.target); + let body = format!("Redirecting: {} -> {}", host, redirect.target); return HttpResponse::Ok().body(body); } }