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_router is example
import popcorn
class AppHome
super Handler
redef fun get(req, res) do res.send "Site Home"
end
class UserLogger
super Handler
redef fun all(req, res) do print "User logged"
end
class UserHomepage
super Handler
redef fun get(req, res) do res.send "User Home"
end
class UserProfile
super Handler
redef fun get(req, res) do res.send "User Profile"
end
var user_router = new Router
user_router.use("/*", new UserLogger)
user_router.use("/", new UserHomepage)
user_router.use("/profile", new UserProfile)
var app = new App
app.use("/", new AppHome)
app.use("/user", user_router)
app.listen("localhost", 3000)
lib/popcorn/examples/routing/example_router.nit:17,1--53,29