Class: Hyperdrive::Middleware::Charset

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Charset

Returns a new instance of Charset.



6
7
8
# File 'lib/hyperdrive/middleware/charset.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  unless %w(OPTIONS TRACE).include? env['REQUEST_METHOD']
    charset = Rack::Accept::Charset.new(env['HTTP_ACCEPT_CHARSET'] || '*')
    Hyperdrive::Utils.enforce_charset!(charset, env['hyperdrive.params'])
  end
  @app.call(env)
end