Class: Rack::CleanCookies::Middleware
- Inherits:
-
Object
- Object
- Rack::CleanCookies::Middleware
- Defined in:
- lib/rack/cleancookies.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {verbose: false}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {verbose: false}) ⇒ Middleware
Returns a new instance of Middleware.
27 28 29 30 |
# File 'lib/rack/cleancookies.rb', line 27 def initialize(app, ={verbose: false}) @app = app @options = end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rack/cleancookies.rb', line 32 def call(env) if env['HTTP_COOKIE'] , = [], [] # Split cookies into clean and dirty env['HTTP_COOKIE'].split(/[;,] */n).each do || if CleanCookies::clean?() << else << end end # Keep only clean cookies env['HTTP_COOKIE'] = .join('; ') # Inform about dropped dirty cookies if !.empty? && @options[:verbose] env['rack.errors'].puts "Ignoring dirty cookies: #{.inspect}" end end # Carry on @app.call(env) end |