Sha256: 09f9b405f612fcbb4eee164a1dc36cdb7761ba8a65919b5f0e38e01e082ff9bc

Contents?: true

Size: 770 Bytes

Versions: 33

Compression:

Stored size: 770 Bytes

Contents

require 'rack/handler'

require_relative '../../falcon'

require 'async/io/host_endpoint'

module Rack
	module Handler
		module Falcon
			SCHEME = "http".freeze
			NAME = :falcon
			
			def self.endpoint_for(**options)
				host = options[:Host] || 'localhost'
				port = Integer(options[:Port] || 9292)
				
				return Async::IO::Endpoint.tcp(host, port)
			end
			
			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
		end
		
		register Falcon::NAME, Falcon
	end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
falcon-0.34.5 lib/rack/handler/falcon.rb
falcon-0.34.4 lib/rack/handler/falcon.rb
falcon-0.34.3 lib/rack/handler/falcon.rb
falcon-0.34.2 lib/rack/handler/falcon.rb
falcon-0.34.1 lib/rack/handler/falcon.rb
falcon-0.34.0 lib/rack/handler/falcon.rb
falcon-0.33.11 lib/rack/handler/falcon.rb
falcon-0.33.10 lib/rack/handler/falcon.rb
falcon-0.33.9 lib/rack/handler/falcon.rb
falcon-0.33.8 lib/rack/handler/falcon.rb
falcon-0.33.7 lib/rack/handler/falcon.rb
falcon-0.33.6 lib/rack/handler/falcon.rb
falcon-0.33.5 lib/rack/handler/falcon.rb
falcon-0.33.4 lib/rack/handler/falcon.rb
falcon-0.33.3 lib/rack/handler/falcon.rb
falcon-0.33.2 lib/rack/handler/falcon.rb
falcon-0.33.1 lib/rack/handler/falcon.rb
falcon-0.33.0 lib/rack/handler/falcon.rb
falcon-0.32.1 lib/rack/handler/falcon.rb
falcon-0.32.0 lib/rack/handler/falcon.rb