diff --git a/database/database.sqlite b/database/database.sqlite index 33b094f..609ffcb 100755 Binary files a/database/database.sqlite and b/database/database.sqlite differ diff --git a/src/main.rs b/src/main.rs index 193e35b..6a6a89a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,22 +13,26 @@ use crate::cors::CORS; #[macro_use] extern crate rocket; use rocket::{ - fs::{relative, FileServer}, - response::Redirect, - Build, Rocket + fs::{relative, FileServer}, + Build, + Rocket }; mod api; mod catchers; +mod redirects; use crate::api::leaderboard::leaderboard; use crate::api::sql::Database; use crate::api::test::{create_test, new_test}; use crate::api::user::{get_tests, login, sign_up}; -use catchers::not_found::api_not_found; -use catchers::not_found::frontend_not_found; -use catchers::not_found::documentation_not_found; +use crate::catchers::not_found::api_not_found; +use crate::catchers::not_found::frontend_not_found; +use crate::catchers::not_found::documentation_not_found; +use crate::redirects::leaderboard_redirect; +use crate::redirects::typing_redirect; + // Imports for sql, see sql.rs for more information @@ -39,11 +43,6 @@ fn test() -> &'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