Module: Flipper::Api
- Defined in:
- lib/flipper/api.rb,
lib/flipper/api/error.rb,
lib/flipper/api/action.rb,
lib/flipper/api/middleware.rb,
lib/flipper/api/json_params.rb,
lib/flipper/api/error_response.rb,
lib/flipper/api/action_collection.rb,
lib/flipper/api/v1/actions/actors.rb,
lib/flipper/api/v1/actions/import.rb,
lib/flipper/api/v1/actions/feature.rb,
lib/flipper/api/v1/decorators/gate.rb,
lib/flipper/api/v1/actions/features.rb,
lib/flipper/api/v1/decorators/actor.rb,
lib/flipper/api/v1/decorators/feature.rb,
lib/flipper/api/v1/actions/actors_gate.rb,
lib/flipper/api/v1/actions/groups_gate.rb,
lib/flipper/api/v1/actions/boolean_gate.rb,
lib/flipper/api/v1/actions/clear_feature.rb,
lib/flipper/api/v1/actions/expression_gate.rb,
lib/flipper/api/v1/actions/percentage_of_time_gate.rb,
lib/flipper/api/v1/actions/percentage_of_actors_gate.rb
Defined Under Namespace
Modules: ErrorResponse, V1 Classes: Action, ActionCollection, JsonParams, Middleware
Constant Summary collapse
- CONTENT_TYPE =
'application/json'.freeze
- Error =
All flipper api errors inherit from this.
Class.new(StandardError)
- RequestMethodNotSupported =
Raised when a request method (get, post, etc.) is called for an action that does not know how to handle it.
Class.new(Error)
Class Method Summary collapse
Class Method Details
.app(flipper = nil, options = {}) {|builder| ... } ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flipper/api.rb', line 10 def self.app(flipper = nil, = {}) env_key = .fetch(:env_key, 'flipper') use_rewindable_middleware = .fetch(:use_rewindable_middleware) { Gem::Version.new(Rack.release) >= Gem::Version.new('3.0.0') } app = ->(_) { [404, { Rack::CONTENT_TYPE => CONTENT_TYPE }, ['{}'.freeze]] } builder = Rack::Builder.new yield builder if block_given? builder.use Rack::Head builder.use Rack::Deflater builder.use Rack::RewindableInput::Middleware if use_rewindable_middleware 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 |