Class: BigSession::RackMiddleware
- Inherits:
-
Object
- Object
- BigSession::RackMiddleware
- Defined in:
- lib/big_session/rack_middleware.rb
Overview
This middleware reads BigSession headers from the request and sets/creates a SessionId usable by the rest of the app
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, header_secret = nil) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app, header_secret = nil) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
17 18 19 20 |
# File 'lib/big_session/rack_middleware.rb', line 17 def initialize(app, header_secret = nil) @app = app @header_secret = header_secret end |
Class Method Details
.activate(header_secret = nil) ⇒ Object
12 13 14 |
# File 'lib/big_session/rack_middleware.rb', line 12 def activate(header_secret = nil) Rails.application.config.middleware.use ::BigSession::RackMiddleware, header_secret end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/big_session/rack_middleware.rb', line 22 def call(env) session_id = retrieve_or_generate_session_id(env) env['rack.session'][::BigSession::RAILS_SESSION_BIG_SESSION_ID_KEY] = session_id SessionId.with_session_id(session_id) do @app.call(env) end end |