Abstract base class for pluggable routing strategies for the Routing plugin.
This class can't be instantiated itself, but it does act as a factory for loading and instantiating its subclasses:
# Create an instance of the default router strategy with the given # routes and options. Strelka::Router.create( 'default', routes, options )
To define your own strategy, you'll need to inherit this class, name it
Strelka::Router::{Something}
, save it in a file named
strelka/router/{something}.rb
, and be sure to override the add_route and route_request methods.
Create a new router that will route requests according to the specified
routes
.
If the optional options
hash is specified, it is passed to the
router strategy.
# File lib/strelka/router.rb, line 42
def initialize( routes=[], options={} )
routes.each do |tuple|
self.log.debug " adding route: %p" % [ tuple ]
self.add_route( *tuple )
end
end
Add a route for the specified http_verb
,
path_array
, and routing_info
. The
http_verb
will be one of the methods from RFC 2616 as a
Symbol (e.g., :GET
, :DELETE
). The
path_array
will be the route path split up by path separator.
The routing_info
is a Hash that contains the action that will
be run when the route matches, routing options, and any other routing
information associated with the route.
# File lib/strelka/router.rb, line 65
pure_virtual :add_route
Determine the most-specific route for the specified request
and return the routing info Hash.
# File lib/strelka/router.rb, line 74
pure_virtual :route_request