File: railtie.rb

package info (click to toggle)
ruby-http-accept-language 2.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 140 kB
  • sloc: ruby: 363; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module HttpAcceptLanguage
  class Railtie < ::Rails::Railtie
    initializer "http_accept_language.add_middleware" do |app|
      app.middleware.use Middleware

      ActiveSupport.on_load :action_controller do
        include EasyAccess
      end
    end
  end

  module EasyAccess
    def http_accept_language
      @http_accept_language ||= request.env["http_accept_language.parser"] || Parser.new(request.env["HTTP_ACCEPT_LANGUAGE"])
    end
  end
end