Sha256: 1664a3f041f42d07ea4afecd3f641e4477639fe82e7e2775f31210b77f439924

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 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.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

2 entries across 2 versions & 2 rubygems

Version Path
browser-1.1.0 test/sample_app.rb
browser2-1.0.0 test/sample_app.rb