mirror of
https://github.com/RGBCube/Site
synced 2025-07-31 13:07:46 +00:00
Make 404 page status code actually 404
This commit is contained in:
parent
69320fe0b8
commit
6a71b16208
2 changed files with 30 additions and 21 deletions
|
@ -1,29 +1,33 @@
|
|||
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 {
|
||||
cube::create(
|
||||
Some("404"),
|
||||
asset::Css::Shared("cube-grid.css"),
|
||||
array::from_fn(|_| {
|
||||
html! {
|
||||
.frame {
|
||||
a href="/" { "404" }
|
||||
pub async fn handler() -> impl IntoResponse {
|
||||
(
|
||||
StatusCode::NOT_FOUND,
|
||||
cube::create(
|
||||
Some("404"),
|
||||
asset::Css::Shared("cube-grid.css"),
|
||||
array::from_fn(|_| {
|
||||
html! {
|
||||
.frame {
|
||||
a href="/" { "404" }
|
||||
}
|
||||
.square .black {}
|
||||
.square .magenta {}
|
||||
.square .magenta {}
|
||||
.square .black {}
|
||||
}
|
||||
.square .black {}
|
||||
.square .magenta {}
|
||||
.square .magenta {}
|
||||
.square .black {}
|
||||
}
|
||||
}),
|
||||
}),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue