Sha256: 7f1e38b7970c13af4f44c9406a5f2c28f683d2cdc8d9c7915914e21e1f015bce

Contents?: true

Size: 894 Bytes

Versions: 14

Compression:

Stored size: 894 Bytes

Contents

require "rails"
require "browser"

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: -> env {
      browser = Rack::Request.new(env).params["browser"]
      [200, default_headers, ["UPGRADE: #{browser}"]]
    }, as: "upgrade"

    get "/asset", to: -> env {
      [200, {"Content-Type" => "image/png"}, []]
    }
  end

  config.middleware.use Browser::Middleware do
    redirect_to upgrade_path(browser: "ie6") if browser.ie6?
    redirect_to upgrade_path(browser: "ie7") if browser.ie7?
    redirect_to "/invalid" if browser.ie8?
  end
end

SampleApp.initialize!

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
browser-1.0.1 test/sample_app.rb
browser-1.0.0 test/sample_app.rb
browser-0.9.1 test/sample_app.rb
browser-0.9.0 test/sample_app.rb
browser-0.8.0 test/sample_app.rb
browser-0.7.2 test/sample_app.rb
browser-0.7.1 test/sample_app.rb
browser-0.7.0 test/sample_app.rb
browser-0.6.0 test/sample_app.rb
browser-0.5.0 test/sample_app.rb
browser-0.4.1 test/sample_app.rb
browser-0.4.0 test/sample_app.rb
browser-0.3.2 test/sample_app.rb
browser-0.3.1 test/sample_app.rb