Class: Async::App::WebServer::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/async/app/web_server.rb

Instance Method Summary collapse

Constructor Details

#initializeRouter

Returns a new instance of Router.



9
10
11
# File 'lib/async/app/web_server.rb', line 9

def initialize
  @apps = []
end

Instance Method Details

#add(app) ⇒ Object



13
# File 'lib/async/app/web_server.rb', line 13

def add(app) = @apps << app

#call(request) ⇒ Object



15
16
17
18
19
# File 'lib/async/app/web_server.rb', line 15

def call(request)
  @apps.reverse_each { return Protocol::HTTP::Response[*_1.call(request)] if _1.can_handle?(request) }

  Protocol::HTTP::Response[404, {}, ["Not found"]]
end