commit e493d7efd96185b5a26ce31f59ab64f20ebb27af
parent 45ca85c6db1a0be5ad15c9b637eb9c5b29aa753c
Author: FIGBERT <figbert@figbert.com>
Date: Mon, 26 Feb 2024 17:34:00 -0800
Redirect all paths to /
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -1,5 +1,5 @@
use askama::Template;
-use axum::{routing::get, Router};
+use axum::{response::Redirect, routing::get, Router};
const COLORS: [&str; 19] = [
"AccentColor",
@@ -54,7 +54,9 @@ struct IndexTemplate {}
#[tokio::main]
async fn main() {
- let app = Router::new().route("/", get(root));
+ let app = Router::new()
+ .route("/", get(root))
+ .fallback(|| async { Redirect::to("/") });
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();