Module: Rack::Handler::Falcon

Defined in:
lib/rack/handler/falcon.rb

Constant Summary collapse

SCHEME =
"http".freeze
NAME =
:falcon

Class Method Summary collapse

Class Method Details

.endpoint_for(**options) ⇒ Object



14
15
16
17
18
19
# File 'lib/rack/handler/falcon.rb', line 14

def self.endpoint_for(**options)
  host = options[:Host] || 'localhost'
  port = Integer(options[:Port] || 9292)
  
  return Async::IO::Endpoint.tcp(host, port)
end

.run(app, **options) {|server| ... } ⇒ Object

Yields:

  • (server)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rack/handler/falcon.rb', line 21

def self.run(app, **options)
  endpoint = endpoint_for(**options)
  
  app = ::Falcon::Adapters::Rack.new(app)
  app = ::Falcon::Adapters::Rewindable.new(app)
  
  server = ::Falcon::Server.new(app, endpoint, Async::HTTP::Protocol::HTTP1, SCHEME)
  yield server if block_given?

  Async::Reactor.run do
    server.run
  end
end