Class: Rage::Application
- Inherits:
-
Object
- Object
- Rage::Application
- Defined in:
- lib/rage/application.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(router) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(router) ⇒ Application
Returns a new instance of Application.
4 5 6 7 8 |
# File 'lib/rage/application.rb', line 4 def initialize(router) @router = router @exception_app = build_exception_app @log_processor = Rage.__log_processor end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rage/application.rb', line 10 def call(env) @log_processor.init_request_logger(env) handler = @router.lookup(env) response = if handler params = Rage::ParamsParser.prepare(env, handler[:params]) handler[:handler].call(env, params) else [404, {}, ["Not Found"]] end rescue Rage::Errors::BadRequest => e response = @exception_app.call(400, e) rescue Exception => e response = @exception_app.call(500, e) ensure @log_processor.finalize_request_logger(env, response, params) end |