From fc86be272fd4863adfd029d2cbb0b40fcf7cd8fe Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 24 Mar 2024 14:54:31 +0000 Subject: feat(response): support redirects --- src/response.rs | 14 ++++++++++++++ src/url.rs | 1 + 2 files changed, 15 insertions(+) (limited to 'src') 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; -- cgit v1.2.3