Class: Rango::Middlewares::Encoding

Inherits:
Object
  • Object
show all
Defined in:
lib/rango/rack/middlewares/encoding.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, encoding = ::Encoding.default_external) ⇒ Encoding

Returns a new instance of Encoding.



7
8
9
10
# File 'lib/rango/rack/middlewares/encoding.rb', line 7

def initialize(app, encoding = ::Encoding.default_external)
  @app = app
  @encoding = encoding
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
# File 'lib/rango/rack/middlewares/encoding.rb', line 12

def call(env)
  env.each do |key, value|
    env[try_force_encoding(key)] = try_force_encoding(value)
  end
  return @app.call(env)
end