clean code
This commit is contained in:
parent
5ec03d06c2
commit
ee626ccd61
24 changed files with 99 additions and 894 deletions
|
|
@ -1,6 +1,6 @@
|
|||
open Tyxml
|
||||
|
||||
let render ~page_title ~scripts content =
|
||||
let generic ~page_title ~scripts content =
|
||||
let open Html in
|
||||
let head =
|
||||
head
|
||||
|
|
@ -10,6 +10,26 @@ let render ~page_title ~scripts content =
|
|||
]
|
||||
@ scripts )
|
||||
in
|
||||
let body = body [ main [ content ] ] in
|
||||
let body = body [ main [ div [ content ] ] ] in
|
||||
let page = html head body in
|
||||
Format.asprintf "%a@." (pp ~indent:true ()) page
|
||||
|
||||
let render ~title ~scripts content =
|
||||
Dream.html @@ generic ~page_title:title ~scripts content
|
||||
|
||||
let err (status, msg) =
|
||||
let code = Dream.status_to_int status in
|
||||
Dream.html ~code @@ generic ~page_title:"Error" ~scripts:[] (Html.txt msg)
|
||||
|
||||
let error _error _debug_info suggested_response =
|
||||
let status = Dream.status suggested_response in
|
||||
let code = Dream.status_to_int status in
|
||||
let reason = Dream.status_to_string status in
|
||||
|
||||
Dream.set_header suggested_response "Content-Type" Dream.text_html;
|
||||
|
||||
let content = Html.txt @@ Format.sprintf "%d: %s" code reason in
|
||||
let body = generic ~page_title:"Error" ~scripts:[] content in
|
||||
|
||||
Dream.set_body suggested_response body;
|
||||
Lwt.return suggested_response
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue