Sha256: 9f20d24c6ae6d5ebc02c9f861513ae6a5d3b028bb7033eca03b8718b73b1718f
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true require "rails" require "browser" class PagesController < ActionController::Base def home render text: "#{browser.name}:#{browser.accept_language.first.full}" end end class SampleApp < Rails::Application config.secret_token = "99f19f08db7a37bdcb9d6701f54dca" config.secret_key_base = "99f19f08db7a37bdcb9d6701f54dca" config.eager_load = true config.active_support.deprecation = :log routes.append do default_headers = {"Content-Type" => "text/html"} root to: -> (_env) { [200, default_headers, ["ROOT"]] } get "upgrade", to: lambda {|env| browser = Rack::Request.new(env).params["browser"] [200, default_headers, ["UPGRADE: #{browser}"]] }, as: "upgrade" get "/asset", to: proc { [200, {"Content-Type" => "image/png"}, []] } get "/home", to: "pages#home" end config.middleware.use Browser::Middleware do redirect_to upgrade_path(browser: "ie6") if browser.ie?(6) redirect_to upgrade_path(browser: "ie7") if browser.ie?(7) redirect_to "/invalid" if browser.ie?(8) end end SampleApp.initialize!
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
browser-2.2.0 | test/sample_app.rb |
browser-2.1.0 | test/sample_app.rb |
browser-2.0.3 | test/sample_app.rb |
browser-2.0.2 | test/sample_app.rb |
browser-2.0.1 | test/sample_app.rb |