Sha256: b86c6b657d0ba99ee5707e689ec9d5c987337ed1df534cbe4395c8c001537d80

Contents?: true

Size: 566 Bytes

Versions: 2

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true
module RackHttpAcceptLanguage
  class Middleware
    def initialize(app)
      @app = app
    end

    def call(env)
      parser = Parser.new(env['HTTP_ACCEPT_LANGUAGE'])
      env['RACK_HTTP_ACCEPT_LANGUAGE'] = parser.preferred_language
      env['RACK_HTTP_ACCEPT_LANGUAGES'] = parser.preferred_languages

      def env.rack_http_accept_languages
        self['RACK_HTTP_ACCEPT_LANGUAGES']
      end

      def env.rack_http_accept_language
        self['RACK_HTTP_ACCEPT_LANGUAGE']
      end

      @app.call(env)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-http-accept-language-0.1.1 lib/rack-http-accept-language/middleware.rb
rack-http-accept-language-0.1.0 lib/rack-http-accept-language/middleware.rb