Sha256: 3de86759d8d9a99864eaabf9d76a2531026173bd01710f4f5bd034731b243d1b

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

require 'rack'
require 'flipper'
require 'flipper/middleware/setup_env'
require 'flipper/middleware/memoizer'
require 'flipper/api/middleware'
require 'flipper/api/json_params'
require 'flipper/api/actor'

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flipper-api-0.11.0.beta4 lib/flipper/api.rb
flipper-api-0.11.0.beta3 lib/flipper/api.rb
flipper-api-0.11.0.beta1 lib/flipper/api.rb