class AcceptHeaders::Middleware

Public Class Methods

new(app) { |self| ... } click to toggle source
# File lib/accept_headers/middleware.rb, line 5
def initialize(app)
  @app = app
  yield self if block_given?
end

Public Instance Methods

call(env) click to toggle source
# File lib/accept_headers/middleware.rb, line 10
def call(env)
  env["accept_headers.media_types"] = MediaType::Negotiator.new(env["HTTP_ACCEPT"])
  env["accept_headers.encodings"] = Encoding::Negotiator.new(env["HTTP_ACCEPT_ENCODING"])
  env["accept_headers.languages"] = Language::Negotiator.new(env["HTTP_ACCEPT_LANGUAGE"])

  @app.call(env)
end