Module: Protocol::Rack::Adapter

Defined in:
lib/protocol/rack/adapter.rb,
lib/protocol/rack/adapter/rack2.rb,
lib/protocol/rack/adapter/rack3.rb,
lib/protocol/rack/adapter/rack31.rb,
lib/protocol/rack/adapter/generic.rb

Overview

The Rack adapter provides a bridge between Protocol::HTTP and Rack applications. It automatically selects the appropriate implementation based on the installed Rack version.

“‘ruby app = ->(env) { [200, => “text/plain”, [“Hello World”]] } adapter = Protocol::Rack::Adapter.new(app) response = adapter.call(request) “`

Defined Under Namespace

Classes: Generic, Rack2, Rack3, Rack31

Constant Summary collapse

VERSION =

The version of Rack being used. Can be overridden using the PROTOCOL_RACK_ADAPTER_VERSION environment variable.

ENV.fetch("PROTOCOL_RACK_ADAPTER_VERSION", ::Rack.release)
IMPLEMENTATION =
Rack2

Class Method Summary collapse

Class Method Details

.make_response(env, response) ⇒ Object

Converts a Rack response into a Protocol::HTTP response.



46
47
48
# File 'lib/protocol/rack/adapter.rb', line 46

def self.make_response(env, response)
  IMPLEMENTATION.make_response(env, response)
end

.new(app) ⇒ Object

Creates a new adapter instance for the given Rack application.



37
38
39
# File 'lib/protocol/rack/adapter.rb', line 37

def self.new(app)
  IMPLEMENTATION.wrap(app)
end

.parse_fileObject

Parses a file path from the Rack environment.



54
55
56
# File 'lib/protocol/rack/adapter.rb', line 54

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