Class: Bruter::Router
- Inherits:
-
HttpRouter
- Object
- HttpRouter
- Bruter::Router
- Defined in:
- lib/bruter/router.rb
Instance Method Summary collapse
-
#process_destination_path(path, env) ⇒ Object
Catches destinations that do not respond to :call(env) and transforms them into a constant, initializes them with Rack request and response objects and the router itself, and invokes :render.
Instance Method Details
#process_destination_path(path, env) ⇒ Object
Catches destinations that do not respond to :call(env) and transforms them into a constant, initializes them with Rack request and response objects and the router itself, and invokes :render. The Rack response’s body will be set to the result of :render and the response finished.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bruter/router.rb', line 8 def process_destination_path(path, env) destination = path.route.dest if destination.respond_to?(:call) destination.call(env) else request = ::Rack::Request.new(env) response = ::Rack::Response.new view = destination.camelize.constantize response.body = [view.new(request, response, self).render] response.finish end end |