Class: FlashSessionCookieMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/flash_session_cookie_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, session_key = ActionController::Base.session_options[:key]) ⇒ FlashSessionCookieMiddleware

Returns a new instance of FlashSessionCookieMiddleware.



4
5
6
7
# File 'lib/flash_session_cookie_middleware.rb', line 4

def initialize(app, session_key = ActionController::Base.session_options[:key])
  @app = app
  @session_key = session_key
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/flash_session_cookie_middleware.rb', line 9

def call(env)
  if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/

    req = Rack::Request.new(env)
    unless req.params[@session_key].nil?
      env['HTTP_COOKIE'] = "#{@session_key}=#{req.params[@session_key].gsub(' ','%2B')}".freeze
    end
  end

  @app.call(env)
end