class RodaSessionMiddleware
See Roda::RodaPlugins::Sessions for details on options.
that uses Roda’s sessions plugin for encrypted and signed cookies.
Session middleware that can be used in any Rack application
def call(env)
returned, then persist the session in the cookie.
application, and if the session has been loaded after the result has been
Initialize the session hash in the environment before calling the next
def call(env) session = env['rack.session'] = SessionHash.new(@req_class.new(nil, env)) res = @app.call(env) if session.loaded? session.req.persist_session(res[1], session.data) end res end
def initialize(app, opts)
Setup the middleware, passing opts
as the Roda sessions plugin options.
def initialize(app, opts) mid = Class.new(Roda) mid.plugin :sessions, opts @req_class = mid::RodaRequest @req_class.send(:include, RequestMethods) @app = app end