From e253848a157e6e2ee4ec81a5693782c8df068cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Fri, 15 Jul 2022 11:16:01 +0200 Subject: [PATCH] Rely on the default error page triggering for 404s It is not immediately obvious how to avoid the error handler making a different 404 response when the application code returns an explicit 404 page. Since we were already replying "Resource not found" in all cases except one where we reply "File not found" not much is lost by relying on the error handler behavior. --- lib/builder_web.ml | 3 --- lib/views.ml | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/lib/builder_web.ml b/lib/builder_web.ml index 0db497e..8f5de34 100644 --- a/lib/builder_web.ml +++ b/lib/builder_web.ml @@ -64,9 +64,6 @@ let or_error_response r = let* r = r in match r with | Ok response -> Lwt.return response - | Error (text, `Not_Found) -> - Views.resource_not_found ~text - |> string_of_html |> Dream.html ~status:`Not_Found | Error (text, status) -> Dream.respond ~status text let default_log_warn ~status e = diff --git a/lib/views.ml b/lib/views.ml index 5498b21..9e5ae72 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -206,16 +206,6 @@ let artifact txtf " (%a)" Fmt.byte_size size; ] -let resource_not_found ~text = - [ - H.h2 ~a:[ H.a_style "padding-top: 33vh" ] - [ txtf "This resource does not exist" ]; - H.p [ - H.txt @@ Fmt.str "Error: '%s'" text - ]; - ] - |> layout ~title:"Resource not found" - let page_not_found ~target ~referer = [ H.h2 ~a:[ H.a_style "padding-top: 33vh" ]