Class: Rack::Unpoly::Middleware
- Inherits:
-
Object
- Object
- Rack::Unpoly::Middleware
- Defined in:
- lib/rack/unpoly/middleware.rb
Overview
Rack Middleware that implements the server protocol expected by Unpoly, and provides an entry point into the Rack::Unpoly::Inspector for the current request.
Accessing the Rack::Unpoly::Inspector
An inspector for the current request is available inside env. You can access any of the inspector methods through this env variable.
env["rack.unpoly"].up?
Middleware Usage Example
require "rack"
require "rack/unpoly/middleware"
use Rack::Unpoly::Middleware
run ->(env) { [200, {}, ["Hello World"]] }
Instance Method Summary collapse
-
#call(env) ⇒ Object
:nodoc:.
-
#initialize(app) ⇒ Middleware
constructor
:nodoc:.
Constructor Details
#initialize(app) ⇒ Middleware
:nodoc:
26 27 28 |
# File 'lib/rack/unpoly/middleware.rb', line 26 def initialize(app) # :nodoc: @app = app end |
Instance Method Details
#call(env) ⇒ Object
:nodoc:
30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/unpoly/middleware.rb', line 30 def call(env) # :nodoc: request = Rack::Request.new(env) env["rack.unpoly"] = Inspector.new(request) status, headers, response = @app.call(env) setup_protocol(request, headers) [status, headers, response] end |