I use middleware class in Rack, Ruby on Rails and Sinatra applications.
Rack application
config.ru:
use Rack::Session::Cookie, key: '_dummy_session', secret: '...'
use MyMiddleware
run Dummy.new
Ruby on Rails application
config/initializers/secret_token.rb:
Dummy::Application.config.secret_key_base = '...'
config/initializers/session_store.rb:
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
config/initializers/my_middleware.rb:
Dummy::Application.config.middleware.use 'MyMiddleware'
Middleware class
lib/my_middleware.rb:
class MyMiddleware
def initialize(app)
@app = app
end
def call(env)
...
@app.call(env)
end
end
How can I get the name of session cookie ('_dummy_session') in MyMiddleware#call
method?