code
nitcorn $ ErrorTemplate :: SELF
Type of this instance, automatically specialized in every classnitcorn $ ErrorTemplate :: rendering
Service used to render the content of the template.core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
nitcorn :: ErrorTemplate :: defaultinit
core :: Writable :: defaultinit
template :: Template :: defaultinit
template :: Template :: is_frozen=
Is the template allowing more modification (add
)
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Writable :: write_to_bytes
Likewrite_to
but return a new Bytes (may be quite large)
core :: Writable :: write_to_file
Likewrite_to
but take care of creating the file
core :: Writable :: write_to_string
Likewrite_to
but return a new String (may be quite large).
# A basic error page for the HTTP error `code`
class ErrorTemplate
super Template
# HTTP error code
var code: Int is writable
# Header on this page
var header: nullable Writable = null is writable
# Body to show with this page
var body: nullable Writable = null is writable
redef fun rendering
do
var code_message = http_status_codes[code]
var message
if code_message != null then
message = "Error {code}: {code_message}"
else message = "Error {code}"
add """
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<title>"""
add message
add """
</title>
</head>
<body>"""
var header = header
if header != null then add header
add """
<div class="container">
<h1>"""
add message
add "</h1>"
var body = body
if body != null then add body
add """
</div>
</body>
</html>"""
end
redef fun to_s do return write_to_string
end
lib/nitcorn/http_errors.nit:24,1--77,3