diff --git a/src/services/about.rs b/src/services/about.rs index 28eedc02..a11bdfb2 100644 --- a/src/services/about.rs +++ b/src/services/about.rs @@ -1,5 +1,4 @@ //! Templates for "about" static pages. -use crate::web::api::server::v1::routes::API_VERSION_URL_PREFIX; #[must_use] pub fn index_page() -> String { @@ -8,8 +7,7 @@ pub fn index_page() -> String { #[must_use] pub fn page() -> String { - format!( - r#" + r#" About @@ -22,17 +20,16 @@ pub fn page() -> String {

Hi! This is a running torrust-index.

"# - ) + .to_string() } #[must_use] pub fn license_page() -> String { - format!( - r#" + r#" Licensing @@ -55,9 +52,8 @@ pub fn license_page() -> String {

If you want to read more about all the licenses and how they apply please refer to the contributor agreement.

-"# - ) +"#.to_string() } diff --git a/src/web/api/server/v1/contexts/about/mod.rs b/src/web/api/server/v1/contexts/about/mod.rs index ef4668d1..02423b4c 100644 --- a/src/web/api/server/v1/contexts/about/mod.rs +++ b/src/web/api/server/v1/contexts/about/mod.rs @@ -35,7 +35,7 @@ //!

Hi! This is a running torrust-index.

//! //! //! //! ``` diff --git a/src/web/api/server/v1/routes.rs b/src/web/api/server/v1/routes.rs index c1666a38..a6049f49 100644 --- a/src/web/api/server/v1/routes.rs +++ b/src/web/api/server/v1/routes.rs @@ -3,13 +3,13 @@ use std::env; use std::sync::Arc; use axum::extract::DefaultBodyLimit; +use axum::response::Redirect; use axum::routing::get; use axum::{Json, Router}; use serde_json::{json, Value}; use tower_http::compression::CompressionLayer; use tower_http::cors::CorsLayer; -use super::contexts::about::handlers::about_page_handler; use super::contexts::{about, category, proxy, settings, tag, torrent, user}; use crate::bootstrap::config::ENV_VAR_CORS_PERMISSIVE; use crate::common::AppData; @@ -23,7 +23,7 @@ pub fn router(app_data: Arc) -> Router { // See: https://stackoverflow.com/questions/6845772/should-i-use-singular-or-plural-name-convention-for-rest-resources let v1_api_routes = Router::new() - .route("/", get(about_page_handler).with_state(app_data.clone())) + .route("/", get(redirect_to_about)) .nest("/user", user::routes::router(app_data.clone())) .nest("/about", about::routes::router(app_data.clone())) .nest("/category", category::routes::router(app_data.clone())) @@ -35,7 +35,7 @@ pub fn router(app_data: Arc) -> Router { .nest("/proxy", proxy::routes::router(app_data.clone())); let router = Router::new() - .route("/", get(about_page_handler).with_state(app_data.clone())) + .route("/", get(redirect_to_about)) .route("/health_check", get(health_check_handler).with_state(app_data)) .nest(&format!("/{API_VERSION_URL_PREFIX}"), v1_api_routes); @@ -52,3 +52,7 @@ pub fn router(app_data: Arc) -> Router { async fn health_check_handler() -> Json { Json(json!({ "status": "Ok" })) } + +async fn redirect_to_about() -> Redirect { + Redirect::permanent(&format!("/{API_VERSION_URL_PREFIX}/about")) +}