Class: Chespirito::App
- Inherits:
-
Object
- Object
- Chespirito::App
- Defined in:
- lib/chespirito/app.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #dispatch(request) ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
- #register_route(verb, path, trait) ⇒ Object
- #register_system_route(key, trait) ⇒ Object
Constructor Details
#initialize ⇒ App
Returns a new instance of App.
8 9 10 |
# File 'lib/chespirito/app.rb', line 8 def initialize @router = ::Chespirito::Router.new end |
Class Method Details
.configure ⇒ Object
12 13 14 15 16 |
# File 'lib/chespirito/app.rb', line 12 def self.configure return unless block_given? new.tap { |app| yield(app) } end |
Instance Method Details
#call(env) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chespirito/app.rb', line 28 def call(env) request = ::Chespirito::Request.build(env) response = dispatch(request) [ response.status, response.headers, [response.body] ] end |
#dispatch(request) ⇒ Object
26 |
# File 'lib/chespirito/app.rb', line 26 def dispatch(request) = @router.dispatch(request) |
#register_route(verb, path, trait) ⇒ Object
18 19 20 |
# File 'lib/chespirito/app.rb', line 18 def register_route(verb, path, trait) @router.register_route(verb, path, trait) end |
#register_system_route(key, trait) ⇒ Object
22 23 24 |
# File 'lib/chespirito/app.rb', line 22 def register_system_route(key, trait) @router.register_system_route(key, trait) end |