Class: Strelka::Router::Exclusive
- Inherits:
-
Default
- Object
- Strelka::Router
- Default
- Strelka::Router::Exclusive
- Extended by:
- Loggability
- Defined in:
- lib/strelka/router/exclusive.rb
Overview
Alternative (stricter) router strategy for Strelka::App::Routing plugin.
Examples
class MyApp < Strelka::App
plugins :routing
router :exclusive
# Unlike the default router, this route will *only* respond to
# a request that matches the app's route with no additional path.
get '' do
# ...
end
end # class MyApp
Instance Attribute Summary
Attributes inherited from Default
Instance Method Summary collapse
-
#add_route(verb, path, route) ⇒ Object
Add a route for the specified
verb,path, andoptionsthat will returnactionwhen a request matches them.
Methods inherited from Default
#initialize, #not_allowed_response, #route_request
Methods included from Strelka::ResponseHelpers
Methods inherited from Strelka::Router
Methods included from AbstractClass
extended, included, #inherited, #pure_virtual
Constructor Details
This class inherits a constructor from Strelka::Router::Default
Instance Method Details
#add_route(verb, path, route) ⇒ Object
Add a route for the specified verb, path, and options that will return
action when a request matches them.
41 42 43 44 45 46 |
# File 'lib/strelka/router/exclusive.rb', line 41 def add_route( verb, path, route ) re = Regexp.compile( '^' + path.join('/') + '$' ) # Make the Hash for the specified HTTP verb if it hasn't been created already self.routes[ re ][ verb ] = route end |