Return 404 for 404 page
Some checks failed
CI / Check typos (push) Successful in 8s
CI / Check links (push) Failing after 13s
CI / Clippy (push) Successful in 54s
CI / Build and test (push) Successful in 1m20s
CI / Build container (push) Has been skipped
CI / Deploy on waypoint (push) Has been skipped

This commit is contained in:
2025-11-14 09:46:18 -08:00
parent 991eb92562
commit 04d98462dd
4 changed files with 10 additions and 1 deletions

View File

@@ -87,6 +87,8 @@ pub struct Page {
&'a RequestContext,
) -> Pin<Box<dyn Future<Output = Markup> + 'a + Send + Sync>>,
>,
pub response_code: StatusCode,
}
impl Default for Page {
@@ -96,6 +98,7 @@ impl Default for Page {
html_ttl: Some(TimeDelta::days(1)),
generate_html: Box::new(|_, _| Box::pin(async { html!() })),
immutable: true,
response_code: StatusCode::OK,
}
}
}
@@ -115,7 +118,7 @@ impl Servable for Page {
let html = self.generate_html(ctx).await;
return Rendered {
code: StatusCode::OK,
code: self.response_code,
body: RenderedBody::Markup(html),
ttl: self.html_ttl,
immutable: self.immutable,

View File

@@ -8,6 +8,7 @@ use chrono::{DateTime, TimeDelta, Utc};
use maud::{Markup, PreEscaped, html};
use page::{DeviceType, RequestContext, page::Page};
use parking_lot::Mutex;
use reqwest::StatusCode;
use serde::Deserialize;
use tracing::{debug, warn};
@@ -201,6 +202,7 @@ pub fn handouts() -> Page {
meta,
html_ttl: Some(TimeDelta::seconds(300)),
immutable: false,
response_code: StatusCode::OK,
generate_html: Box::new(move |page, ctx| {
let html = html.clone(); // TODO: find a way to not clone here

View File

@@ -1,6 +1,7 @@
use chrono::TimeDelta;
use maud::{DOCTYPE, Markup, PreEscaped, html};
use page::page::{Page, PageMetadata};
use reqwest::StatusCode;
use std::pin::Pin;
use crate::components::{
@@ -69,6 +70,7 @@ fn page_from_markdown(md: impl Into<String>, default_image: Option<String>) -> P
Page {
meta,
immutable: true,
response_code: StatusCode::OK,
html_ttl: Some(TimeDelta::days(1)),
generate_html: Box::new(move |page, ctx| {

View File

@@ -1,5 +1,6 @@
use maud::html;
use page::page::{Page, PageMetadata};
use reqwest::StatusCode;
use crate::pages::page_wrapper;
@@ -13,6 +14,7 @@ pub fn notfound() -> Page {
backlinks: Some(false),
},
response_code: StatusCode::NOT_FOUND,
generate_html: Box::new(move |page, _ctx| {
Box::pin(async {
let inner = html! {