From 52624bd056c8f77423146c45f211172f9262733f Mon Sep 17 00:00:00 2001 From: ArloFilley Date: Sat, 23 Mar 2024 00:13:42 +0000 Subject: [PATCH] added redirects --- database/database.sqlite | Bin 16384 -> 16384 bytes src/main.rs | 25 +++++++++++++------------ src/redirects.rs | 11 +++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 src/redirects.rs diff --git a/database/database.sqlite b/database/database.sqlite index 33b094ffa286edee183349d6091bfb09e4d10c31..609ffcb6ddacb2331d7fb33dc79c1ec43acdc3cc 100755 GIT binary patch delta 270 zcmZo@U~Fh$oFL68GEv5vRfIvWXu-ym1^hznJQWQ5<$OQ+%6LEVmhyb(so2<<#8Y3( z&c-0#$Xl3Ll#_2{l$>T{l9H5YnwDgcXl#&bWR_}SoMe=kY?@@5YGj#em}F>Xm};7A zn3ia6Vq}_XZfsy;Y;0y^X>5^XX<=j%Txt^T9+6j6QsEcw8tz_f7#>)V9cFBh z?3qzoTJDq>8e-}0?&lGdo?Dq0R=)YW3@ &'static str { "Hello World! I'm A rocket Webserver" } -#[get("/")] -async fn typing_redirect() -> Redirect { - Redirect::to(uri!("/typing/index.html")) -} - /// The main function which builds and launches the /// webserver with all appropriate routes and fileservers #[launch] @@ -69,12 +68,14 @@ async fn rocket() -> Rocket { // hosts the fileserver - .mount("/typing", routes![typing_redirect]) .mount("/typing", FileServer::from(relative!("public"))) .register("/typing", catchers![frontend_not_found]) // The state which allows routes to access the database .manage(Database::new().await.unwrap()) + // Redirects + .mount("/typing", routes![typing_redirect]) + .mount("/leaderboard", routes![leaderboard_redirect]) // testing only, should return "Hello world" .mount("/test", routes![test]) diff --git a/src/redirects.rs b/src/redirects.rs new file mode 100644 index 0000000..922cbbb --- /dev/null +++ b/src/redirects.rs @@ -0,0 +1,11 @@ +use rocket::response::Redirect; + +#[get("/")] +pub async fn typing_redirect() -> Redirect { + Redirect::to(uri!("/typing/index.html")) +} + +#[get("/")] +pub async fn leaderboard_redirect() -> Redirect { + Redirect::to(uri!("/typing/leaderboard/index.html")) +} \ No newline at end of file