rename to game, add 404 page

This commit is contained in:
2025-08-02 15:59:51 +02:00
parent b45b962831
commit bedfabff9f
2 changed files with 27 additions and 22 deletions

56
src/game.rs Normal file
View File

@@ -0,0 +1,56 @@
use crate::{client_id, page::new};
use axum::{
extract::Path,
response::{IntoResponse, Response},
routing::get,
Router,
};
use axum_extra::extract::CookieJar;
use maud::{html, Markup, PreEscaped};
use uuid::Uuid;
fn page(content: Markup) -> Markup {
new(html! {
hgroup {
h1 { "Digital Shadows" (PreEscaped("—")) "Who finds the most cameras?" }
(content)
}
})
}
async fn index() -> Markup {
page(html! {})
}
async fn game(cookies: CookieJar, Path(uuid): Path<String>) -> Response {
let (cookies, device) = client_id(cookies);
let Ok(uuid) = Uuid::parse_str(&uuid) else {
return not_found().await.into_response();
};
let markup = new(html! {
hgroup {
h1 { "Digital Shadows" (PreEscaped("&mdash;")) "Who finds the most cameras?" }
h2 {
(device)
" found camera "
(uuid)
}
}
});
(cookies, markup).into_response()
}
async fn not_found() -> Markup {
new(html! {
h1 { "uups" }
})
}
pub(super) fn routes() -> Router {
Router::new()
.route("/game", get(index))
.route("/{*uuid}", get(game))
}