FileServer
action, which is a standard and minimal file server
HttpRequest
class and services to create it
Serializable::inspect
to show more useful information
more_collections :: more_collections
Highly specific, but useful, collections-related classes.serialization :: serialization_core
Abstract services to serialize Nit objects to different formatscore :: union_find
union–find algorithm using an efficient disjoint-set data structure
module example_html_error_handler is example
import popcorn
import template
class HtmlErrorTemplate
super Template
var status: Int
var message: nullable String
redef fun rendering do add """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{{message or else status}}}</title>
</head>
<body>
<h1>{{{status}}} {{{message or else ""}}}</h1>
</body>
</html>"""
end
class HtmlErrorHandler
super Handler
redef fun all(req, res) do
if res.status_code != 200 then
res.send(new HtmlErrorTemplate(res.status_code, "An error occurred!"))
end
end
end
var app = new App
app.use("/*", new HtmlErrorHandler)
app.listen("localhost", 3000)
lib/popcorn/examples/middlewares/example_html_error_handler.nit:17,1--53,29