Sha256: afd3c50ade7be05dd17ed84880815c1288735fdbf840cb84393ff1e72b4ccb2b

Contents?: true

Size: 793 Bytes

Versions: 17

Compression:

Stored size: 793 Bytes

Contents

require 'rack'
require 'flipper'
require 'flipper/api/middleware'
require 'flipper/api/json_params'

module Flipper
  module Api
    CONTENT_TYPE = 'application/json'.freeze

    def self.app(flipper = nil, options = {})
      env_key = options.fetch(:env_key, 'flipper')
      app = ->(_) { [404, { 'Content-Type'.freeze => CONTENT_TYPE }, ['{}'.freeze]] }
      builder = Rack::Builder.new
      yield builder if block_given?
      builder.use Flipper::Api::JsonParams
      builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
      builder.use Flipper::Api::Middleware, env_key: env_key
      builder.run app
      klass = self
      app = builder.to_app
      app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
      app
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
flipper-api-0.28.3 lib/flipper/api.rb
flipper-api-0.28.2 lib/flipper/api.rb
flipper-api-0.28.1 lib/flipper/api.rb
flipper-api-0.28.0 lib/flipper/api.rb
flipper-api-0.27.1 lib/flipper/api.rb
flipper-api-0.27.0 lib/flipper/api.rb
flipper-api-0.26.2 lib/flipper/api.rb
flipper-api-0.26.1 lib/flipper/api.rb
flipper-api-0.26.0 lib/flipper/api.rb
flipper-api-0.26.0.rc2 lib/flipper/api.rb
flipper-api-0.26.0.rc1 lib/flipper/api.rb
flipper-api-0.25.4 lib/flipper/api.rb
flipper-api-0.25.3 lib/flipper/api.rb
flipper-api-0.25.2 lib/flipper/api.rb
flipper-api-0.25.1 lib/flipper/api.rb
flipper-api-0.25.0 lib/flipper/api.rb
flipper-api-0.24.1 lib/flipper/api.rb