aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-03-24 14:54:31 +0000
committerFuwn <[email protected]>2024-03-24 14:54:51 +0000
commitfc86be272fd4863adfd029d2cbb0b40fcf7cd8fe (patch)
tree8f977ddad760d06e14e5286d032a937670cc9551
parentformat(response): capitalisation (diff)
downloadseptember-fc86be272fd4863adfd029d2cbb0b40fcf7cd8fe.tar.xz
september-fc86be272fd4863adfd029d2cbb0b40fcf7cd8fe.zip
feat(response): support redirects
-rw-r--r--Cargo.toml2
-rw-r--r--src/response.rs14
-rw-r--r--src/url.rs1
3 files changed, 16 insertions, 1 deletions
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 <[email protected]>"]
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!(
+ "<p>This page permanently redirects to <a href=\"{}\">{}</a>.</p>",
+ response.meta(),
+ response.meta().trim()
+ ));
+ }
+ germ::request::Status::TemporaryRedirect => {
+ html_context.push_str(&format!(
+ "<p>This page temporarily redirects to <a href=\"{}\">{}</a>.</p>",
+ response.meta(),
+ response.meta().trim()
+ ));
+ }
_ => html_context.push_str(&format!("<p>{}</p>", 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<Url, url::ParseError> {
Ok(
+ #[allow(clippy::blocks_in_conditions)]
match Url::try_from(&*if path.starts_with("/proxy") {
*is_proxy = true;