Protocol::RackSourceProtocolRackAdapter

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 app Interface(: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 env Hash

The Rack environment.

parameter response Array

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 path String

The path to the Rackup file.

returns Interface(:call)

The parsed Rack application.

Implementation

def self.parse_file(...)
	IMPLEMENTATION.parse_file(...)
end