From cf98738a0df699426d265ef93b8899c9aae9cc43 Mon Sep 17 00:00:00 2001 From: Eren AY Date: Wed, 12 Jun 2024 11:55:30 +0200 Subject: [PATCH] Fixed redirection to paths not ending with a slash --- src/main.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3df57db..4c8cc79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,8 @@ use { providers::{Env, Format as _, Toml}, Profile, }, - response::Responder, + http::uri::Origin, + response::{Redirect, Responder}, serde::Serialize, State, }, @@ -29,6 +30,8 @@ enum FileView { #[response(content_type = "application/octet-stream")] File(Vec), + + Redirect(Redirect), } #[derive(Serialize)] @@ -49,7 +52,11 @@ enum Error { } #[rocket::get("/")] -async fn index(path: PathBuf, state: &State) -> Result { +async fn index( + path: PathBuf, + uri: &Origin<'_>, + state: &State, +) -> Result { /* The way things work in S3, the following holds for us: - we need to use a slash as separator @@ -61,10 +68,17 @@ async fn index(path: PathBuf, state: &State) -> Result