make redirect from '/'
All checks were successful
CI/CD Pipeline / test (push) Successful in 4m13s
CI/CD Pipeline / deploy (push) Successful in 2m42s

This commit is contained in:
Philipp Hofer 2025-04-13 08:39:29 +02:00
parent 513518215d
commit 9fc4dde550

View File

@ -18,7 +18,13 @@ i18n!("locales", fallback = "de-AT");
use admin::station::Station; use admin::station::Station;
use auth::Backend; use auth::Backend;
use axum::{body::Body, extract::FromRef, response::Response, routing::get, Router}; use axum::{
body::Body,
extract::FromRef,
response::{IntoResponse, Redirect, Response},
routing::get,
Router,
};
use axum_login::AuthManagerLayerBuilder; use axum_login::AuthManagerLayerBuilder;
use partials::page; use partials::page;
use sqlx::SqlitePool; use sqlx::SqlitePool;
@ -148,6 +154,10 @@ async fn logo_ver_inv() -> Response<Body> {
.unwrap() .unwrap()
} }
async fn redirect() -> impl IntoResponse {
Redirect::to("/admin")
}
#[derive(Clone)] #[derive(Clone)]
struct AppState { struct AppState {
db: Arc<SqlitePool>, db: Arc<SqlitePool>,
@ -172,6 +182,7 @@ fn router(db: SqlitePool) -> Router {
let state = AppState { db: Arc::new(db) }; let state = AppState { db: Arc::new(db) };
Router::new() Router::new()
.route("/", get(redirect))
.nest("/s/{id}/{code}", station::routes()) // TODO: maybe switch to "/" .nest("/s/{id}/{code}", station::routes()) // TODO: maybe switch to "/"
.nest("/admin", admin::routes()) .nest("/admin", admin::routes())
.nest("/auth", auth::routes()) .nest("/auth", auth::routes())