added: 404 to bad pages
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 2 May 2023 03:25:56 +0000 (22:25 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 2 May 2023 03:25:56 +0000 (22:25 -0500)
src/app.onyx

index ec3d3c30654d63fee0f5474d5c0726dfeccdf037..fb9c79d70c0bb50c0422ea2823d59c192d1322b4 100644 (file)
@@ -43,7 +43,11 @@ news_articles: Cached_Resource([] Article);
 @route.{.GET, "/news/:article"}
 (req: &Req, res: &Res) {
     article := array.first(news_articles->get() ?? .[], #(it.path == req.url_params["article"]));
-    if !article do return;
+    if !article {
+        res->status(404);
+        res->render("pages/404", null);
+        return;
+    }
 
     filename := tprintf("www/news-articles/{}.html", article.path);