Class: Ckeditor::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, session_key = '_session_id') ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
8
# File 'lib/ckeditor/middleware.rb', line 5

def initialize(app, session_key = '_session_id')
  @app = app
  @session_key = session_key
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ckeditor/middleware.rb', line 10

def call(env)
  if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
    params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
    env['HTTP_COOKIE'] = [ @session_key, ::Rack::Utils.escape(params[@session_key]) ].join('=').freeze unless params[@session_key].nil?
  end
  @app.call(env)
end