From cf43656041f3b13fb5c3c87cd4643d7e885ea9c5 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 24 Mar 2024 07:54:31 -0700 Subject: [PATCH] feat(response): support redirects --- Cargo.toml | 2 +- src/response.rs | 14 ++++++++++++++ src/url.rs | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f8045ed..a907534 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.2.11" +version = "0.2.12" authors = ["Fuwn "] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." diff --git a/src/response.rs b/src/response.rs index 345f6f5..717da4c 100644 --- a/src/response.rs +++ b/src/response.rs @@ -201,6 +201,20 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< germ::request::Status::Success => { html_context.push_str(&gemini_html.1); } + germ::request::Status::PermanentRedirect => { + html_context.push_str(&format!( + "

This page permanently redirects to {}.

", + response.meta(), + response.meta().trim() + )); + } + germ::request::Status::TemporaryRedirect => { + html_context.push_str(&format!( + "

This page temporarily redirects to {}.

", + response.meta(), + response.meta().trim() + )); + } _ => html_context.push_str(&format!("

{}

", response.meta())), } diff --git a/src/url.rs b/src/url.rs index f5ab5d9..8f510aa 100644 --- a/src/url.rs +++ b/src/url.rs @@ -25,6 +25,7 @@ pub fn make( is_nocss: &mut bool, ) -> Result { Ok( + #[allow(clippy::blocks_in_conditions)] match Url::try_from(&*if path.starts_with("/proxy") { *is_proxy = true;