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

Inherits:
Object
  • Object
show all
Extended by:
Injector
Defined in:
lib/async/app/web_server/router.rb

Instance Method Summary collapse

Methods included from Injector

inject

Constructor Details

#initialize(*apps) ⇒ Router

Returns a new instance of Router.



6
7
8
# File 'lib/async/app/web_server/router.rb', line 6

def initialize(*apps)
  @apps = apps
end

Instance Method Details

#call(request) ⇒ Object



10
11
12
13
14
# File 'lib/async/app/web_server/router.rb', line 10

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

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