Compare commits

...
1 Commits
Author SHA1 Message Date
Markk116 54982bcc62 Add terse 404 fallback (no route hints, keep obscurity) 2026-08-09 07:55:32 +02:00
+11 -1
View File
@@ -438,6 +438,16 @@ fn fetch_asset_handler(c: Conn, _n: Next) -> Conn {
}
}
/// Fallback for any request the router didn't match. Deliberately terse -
/// no route list, no hint of the `/assets/:package/:version/:filename`
/// shape, nothing to make this service more discoverable to strangers
/// than it already is. Just enough to not look like a hung connection.
fn not_found_handler(c: Conn, _n: Next) -> Conn {
c.put_status(404)
.put_header("content-type", "text/plain")
.put_body("404 not found")
}
fn main() {
let Some(port) = run_cli() else { return };
@@ -451,6 +461,6 @@ fn main() {
println!("C3 on 0.0.0.0:{port}...");
let cfg = Config::new(format!("0.0.0.0:{port}").parse().unwrap());
let pipeline = Pipeline::new().plug(router);
let pipeline = Pipeline::new().plug(router).plug(not_found_handler);
serve_with(cfg, pipeline).unwrap();
}