class Wrapper
Implements a wrapper for starting the Falcon server for Capybara.
Definitions
def initialize(scheme = "http")
Signature
-
parameter
schemeString The scheme for the server to bind to. e.g.
httporhttps.
Implementation
def initialize(scheme = "http")
@scheme = scheme
end
def endpoint(host, port)
Build a server endpoint using the given scheme.
Implementation
def endpoint(host, port)
Falcon::Endpoint.parse("#{@scheme}://#{host}:#{port}")
end
def call(rack_app, port, host, options = {})
Run the Falcon server hosting the given rack application.
Signature
-
parameter
rack_appProc A Rack application.
-
parameter
portInteger The port number to bind to.
-
parameter
hostString The local host to bind to.
-
parameter
optionsHash Options to pass to the server
Implementation
def call(rack_app, port, host, options = {})
require 'async/reactor'
require 'falcon/server'
Async do |task|
app = Falcon::Server.middleware(rack_app)
if host == "127.0.0.1"
host = "localhost"
end
endpoint = self.endpoint(host, port)
server = Falcon::Server.new(app, endpoint, protocol: endpoint.protocol, scheme: endpoint.scheme)
Console.logger.debug (self) {"Running server..."}
server.run
end
end