class CacheableFlash::Middleware

Constants

FLASH_HASH_KEY

Public Class Methods

new(app) click to toggle source
# File lib/cacheable_flash/middleware.rb, line 8
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/cacheable_flash/middleware.rb, line 12
def call(env)
  status, headers, body = @app.call(env)
  env_flash = env[FLASH_HASH_KEY]

  if env_flash
    domain = CacheableFlash::Config.config[:domain]
    cookies = Rack::Request.new(env).cookies
    Rack::Utils.set_cookie_header!(headers, "flash", :value => cookie_flash(env_flash, cookies), :path => "/", :domain => domain)
  end

  [status, headers, body]
end