module Adapter
The Rack adapter provides a bridge between Protocol::HTTP and Rack applications. It automatically selects the appropriate implementation based on the installed Rack version.
app = ->(env) { [200, {"content-type" => "text/plain"}, ["Hello World"]] }
adapter = Protocol::Rack::Adapter.new(app)
response = adapter.call(request)
Nested
Definitions
VERSION = ENV.fetch("PROTOCOL_RACK_ADAPTER_VERSION", ::Rack.release)
The version of Rack being used. Can be overridden using the PROTOCOL_RACK_ADAPTER_VERSION environment variable.
def self.new(app)
Creates a new adapter instance for the given Rack application.
Signature
-
parameter
appInterface(:call) A Rack application that responds to
call.-
returns
Protocol::HTTP::Middleware An adapter that can handle HTTP requests.
Implementation
def self.new(app)
IMPLEMENTATION.wrap(app)
end
def self.make_response(env, response)
Converts a Rack response into a Protocol::HTTP::Response.
Signature
-
parameter
envHash The Rack environment.
-
parameter
responseArray The Rack response tuple
[status, headers, body].-
returns
Protocol::HTTP::Response A Protocol::HTTP response.
Implementation
def self.make_response(env, response)
IMPLEMENTATION.make_response(env, response)
end
def self.parse_file(...)
Parses a Rackup file and returns the application.
Signature
-
parameter
pathString The path to the Rackup file.
-
returns
Interface(:call) The parsed Rack application.
Implementation
def self.parse_file(...)
IMPLEMENTATION.parse_file(...)
end