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.
This commit is contained in:
Reynir Björnsson 2022-07-15 11:16:01 +02:00
parent 234c7a0cb2
commit e253848a15
2 changed files with 0 additions and 13 deletions

View file

@ -64,9 +64,6 @@ let or_error_response r =
let* r = r in let* r = r in
match r with match r with
| Ok response -> Lwt.return response | 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 | Error (text, status) -> Dream.respond ~status text
let default_log_warn ~status e = let default_log_warn ~status e =

View file

@ -206,16 +206,6 @@ let artifact
txtf " (%a)" Fmt.byte_size size; 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 = let page_not_found ~target ~referer =
[ [
H.h2 ~a:[ H.a_style "padding-top: 33vh" ] H.h2 ~a:[ H.a_style "padding-top: 33vh" ]