class Wrapper
Implements a wrapper for starting the Falcon server for Capybara.
Definitions
def initialize(scheme = "http")
Signature
-
parameter
scheme
String
The scheme for the server to bind to. e.g.
http
orhttps
.
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)
Run the Falcon server hosting the given rack application.
Signature
-
parameter
rack_app
Proc
A Rack application.
-
parameter
port
Integer
The port number to bind to.
-
parameter
host
String
The local host to bind to.
Implementation
def call(rack_app, port, host)
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