Rocket::Router
Inherits HTTP::Handler < Reference < Object
Is responsible for definning routes, instantiating controllers and routing incoming context from the server to the corresponding controller's action. Acts as a middleware (see: HTTP::Handler)
Adding a route:
router = Rocket::Router.new
router.add_route("GET", "/", WelcomeController, "index")
router.add_route("POST", "/users", UsersController, "create")
Assuming WelcomeController and UsersController inherit from
Rocket::Controller.
The instance is composed of an array of Rocket::Route which stores
all the routes added by #add_route
and a Hash which stores the name of the controller's class and an
instance of it.
Constructors
Instance methods
Creates a route based on the HTTP method, the URL path to be matched, the instantiated controller and the controller's action to call.
As a middleware, it is called by the server with a context
If the request matches with a route it performs
a routing by calling the correct controller's action and printing the
result into the response. If no routes matches, raises
Exceptions::RouteNotFound.