package dream

  1. Overview
  2. Docs

Source file error_template.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#1 "src/server/error_template.eml.ml"
(* This file is part of Dream, released under the MIT license. See LICENSE.md
   for details, or visit https://github.com/aantron/dream.

   Copyright 2021 Anton Bachin *)



module Dream =
struct
  include Dream_pure
  include Dream_pure.Formats
end
(* This slightly awkward simulation of the overall Dream module using a
   composition of internal modules is necessary to get all the helpers at the
   right positions expected by the EML templater. *)



let render ~debug_dump ~code ~reason =
let ___eml_buffer = Buffer.create 4096 in
(Buffer.add_string ___eml_buffer "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" />\n    <style>\n\n    body {\n      color: rgb(17, 24, 39);\n      font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;\n      margin: 3rem 2rem;\n    }\n\n    h1 {\n      font-weight: 600;\n      margin: 0;\n    }\n\n    h2 {\n      font-weight: normal;\n    }\n\n    h3 {\n      font-size: 16px;\n      font-weight: normal;\n      border: 1px solid #ddd;\n      margin: 0;\n      padding: 1rem 1.5rem;\n    }\n\n    pre {\n      background-color: rgb(31, 41, 55);\n      color: white;\n      font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;\n      font-size: 16px;\n      line-height: 1.5;\n      margin: 0;\n      padding: 1rem;\n    }\n\n    </style>\n    <title>");
(Printf.bprintf ___eml_buffer "%i" (
#61 "src/server/error_template.eml.ml"
                 code 
));
(Buffer.add_string ___eml_buffer " ");
(Printf.bprintf ___eml_buffer "%s" (Dream.html_escape (
#61 "src/server/error_template.eml.ml"
                             reason 
)));
(Buffer.add_string ___eml_buffer "</title>\n  </head>\n\n  <body>\n    <h1>An error occured!</h1>\n    <h2>");
(Printf.bprintf ___eml_buffer "%i" (
#66 "src/server/error_template.eml.ml"
              code 
));
(Buffer.add_string ___eml_buffer " ");
(Printf.bprintf ___eml_buffer "%s" (Dream.html_escape (
#66 "src/server/error_template.eml.ml"
                          reason 
)));
(Buffer.add_string ___eml_buffer "</h2>\n    <p>\n      This error page has been generated by Dream's error handler.<br />\n      Remember to turn debugging mode off when deploying your application in\n      production.\n    </p>\n    <h3>Debug Dump</h3>\n    <pre><code>");
(Printf.bprintf ___eml_buffer "%s" (Dream.html_escape (
#73 "src/server/error_template.eml.ml"
                     debug_dump 
)));
(Buffer.add_string ___eml_buffer "</code></pre>\n  </body>\n</html>\n");
(Buffer.contents ___eml_buffer)
OCaml

Innovation. Community. Security.