Sha256: 4449f6fa400fbf6cfb9880a537133313eaf1a12ea9251462fd226662533cd615

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

#
# Usage:
#   bundle exec rackup examples/ui/authorization.ru -p 9999
#   http://localhost:9999/
#
require 'bundler/setup'
require 'rack/reloader'
require "flipper/ui"
require "flipper/adapters/pstore"

Flipper.register(:admins) { |actor|
  actor.respond_to?(:admin?) && actor.admin?
}

# Example middleware to allow reading the Flipper UI but nothing else.
class FlipperReadOnlyMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    request = Rack::Request.new(env)

    if request.get?
      @app.call(env)
    else
      [401, {}, ["You can only look"]]
    end
  end
end

# You can uncomment these to get some default data:
# Flipper.enable(:search_performance_another_long_thing)
# Flipper.disable(:gauges_tracking)
# Flipper.disable(:unused)
# Flipper.enable_actor(:suits, Flipper::Actor.new('1'))
# Flipper.enable_actor(:suits, Flipper::Actor.new('6'))
# Flipper.enable_group(:secrets, :admins)
# Flipper.enable_percentage_of_time(:logging, 5)
# Flipper.enable_percentage_of_actors(:new_cache, 15)
# Flipper.add("a/b")

use Rack::Reloader

run Flipper::UI.app { |builder|
  builder.use Rack::Session::Cookie, secret: "_super_secret"
  builder.use FlipperReadOnlyMiddleware
}

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
flipper-ui-1.3.2 examples/ui/authorization.ru
flipper-ui-1.3.1 examples/ui/authorization.ru
flipper-ui-1.3.0 examples/ui/authorization.ru
flipper-ui-1.3.0.pre examples/ui/authorization.ru
flipper-ui-1.2.2 examples/ui/authorization.ru
flipper-ui-1.2.1 examples/ui/authorization.ru
flipper-ui-1.2.0 examples/ui/authorization.ru
flipper-ui-1.1.2 examples/ui/authorization.ru
flipper-ui-1.1.1 examples/ui/authorization.ru
flipper-ui-1.1.0 examples/ui/authorization.ru
flipper-ui-1.0.0 examples/ui/authorization.ru
flipper-ui-1.0.0.pre examples/ui/authorization.ru
flipper-ui-0.28.3 examples/ui/authorization.ru
flipper-ui-0.28.2 examples/ui/authorization.ru
flipper-ui-0.28.1 examples/ui/authorization.ru