Sha256: a14aa4aa8fbc1cafc41bf51d37934a659d8e1a5bf1cdb8768198693f0179fa75

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

require "accept_headers"

module AcceptHeaders
  class Middleware
    def initialize(app)
      @app = app
      yield self if block_given?
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
accept_headers-0.1.0 lib/accept_headers/middleware.rb
accept_headers-0.0.9 lib/accept_headers/middleware.rb