feat: support customizable 404 page (#688)

This commit is contained in:
sigoden
2026-04-24 08:20:19 +08:00
committed by GitHub
parent a88a4ee630
commit 0ccc2cf1e7
3 changed files with 74 additions and 7 deletions
+8
View File
@@ -295,6 +295,7 @@ pub struct Args {
pub render_try_index: bool,
pub enable_cors: bool,
pub assets: Option<PathBuf>,
pub error_page: Option<PathBuf>,
#[serde(deserialize_with = "deserialize_log_http")]
#[serde(rename = "log-format")]
pub http_logger: HttpLogger,
@@ -410,6 +411,13 @@ impl Args {
args.assets = Some(Args::sanitize_assets_path(assets_path)?);
}
if let Some(assets_path) = &args.assets {
let p = assets_path.join("404.html");
if p.exists() {
args.error_page = Some(p);
}
}
if let Some(log_format) = matches.get_one::<String>("log-format") {
args.http_logger = log_format.parse()?;
}