1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +00:00

Make 404 page status code actually 404

This commit is contained in:
RGBCube 2024-01-09 10:54:19 +03:00
parent 69320fe0b8
commit 6a71b16208
No known key found for this signature in database
2 changed files with 30 additions and 21 deletions

View file

@ -1,16 +1,19 @@
use std::array;
use maud::{
html,
Markup,
use axum::{
http::StatusCode,
response::IntoResponse,
};
use maud::html;
use crate::{
asset,
page::cube,
};
pub async fn handler() -> Markup {
pub async fn handler() -> impl IntoResponse {
(
StatusCode::NOT_FOUND,
cube::create(
Some("404"),
asset::Css::Shared("cube-grid.css"),
@ -25,5 +28,6 @@ pub async fn handler() -> Markup {
.square .black {}
}
}),
),
)
}

View file

@ -1,6 +1,11 @@
use std::sync::LazyLock;
use axum::extract::Path;
use axum::{
body::Body,
extract::Path,
http::Response,
response::IntoResponse,
};
use indexmap::IndexMap;
use itertools::Itertools;
use maud::{
@ -70,10 +75,10 @@ pub async fn index_handler() -> Markup {
)
}
pub async fn entry_handler(Path(entry): Path<String>) -> Markup {
pub async fn entry_handler(Path(entry): Path<String>) -> Response<Body> {
if let Some((metadata, body)) = ENTRIES.get(entry.as_str()) {
text::create(Some(&metadata.title), Page::Other, body)
text::create(Some(&metadata.title), Page::Other, body).into_response()
} else {
not_found::handler().await
not_found::handler().await.into_response()
}
}