[OCaml] High Intensity Training Online
1
(** Branded error pages. These pages expose no domain or service detail. *)
2
3
open Dream_html
4
open Page_kit
5
open Page_shell
6
7
let problem ~title ~detail =
8
html_page title
9
[
10
tag "p" [ class_ "eyebrow" ] [ txt "Attention required" ];
11
tag "h1" [] [ txt "%s" title ];
12
tag "p" [ class_ "warn" ] [ txt "%s" detail ];
13
]
14
15
let error_page ?viewer ?request ~status () =
16
let title, detail =
17
match status with
18
| 404 ->
19
("Page not found", "That page does not exist. Use the navigation below.")
20
| 400 -> ("Bad request", "That request could not be understood.")
21
| 403 -> ("Forbidden", "You do not have access to that page.")
22
| s when s >= 500 ->
23
("Something went wrong", "The server hit a problem. Try again shortly.")
24
| _ -> ("Something went wrong", "That request could not be completed.")
25
in
26
html_page ?viewer ?request ~show_nav:true title
27
[
28
tag "p" [ class_ "eyebrow" ] [ txt "%d" status ];
29
tag "h1" [] [ txt "%s" title ];
30
tag "p" [ class_ "warn" ] [ txt "%s" detail ];
31
]
32