Class: Reins::Application
- Inherits:
-
Object
- Object
- Reins::Application
- Defined in:
- lib/reins.rb
Class Attribute Summary collapse
-
.instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #dispatch_request(env) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #route ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
78 79 80 |
# File 'lib/reins.rb', line 78 def initialize Reins::Application.instances << self end |
Class Attribute Details
.instances ⇒ Object (readonly)
Returns the value of attribute instances.
73 74 75 |
# File 'lib/reins.rb', line 73 def instances @instances end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
76 77 78 |
# File 'lib/reins.rb', line 76 def routes @routes end |
Instance Method Details
#call(env) ⇒ Object
88 89 90 91 |
# File 'lib/reins.rb', line 88 def call(env) @rack_app ||= build_rack_app @rack_app.call(env) end |
#dispatch_request(env) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/reins.rb', line 93 def dispatch_request(env) return [404, { 'content-type' => 'text/html' }, []] if env['PATH_INFO'] == '/favicon.ico' verb = env['REQUEST_METHOD'].downcase.to_sym path = env['PATH_INFO'] result = @routes&.check(verb, path) return not_found if result.nil? begin result.call(env) rescue Reins::Error raise rescue StandardError server_error end end |