Class: Flipper::Api::V1::Actions::Import
- Defined in:
- lib/flipper/api/v1/actions/import.rb
Constant Summary
Constants inherited from Action
Action::VALID_REQUEST_METHOD_NAMES
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
Methods inherited from Action
#halt, #header, #initialize, #json_error_response, #json_response, route, route_match?, route_regex, #run, run, #run_other_action, #status
Constructor Details
This class inherits a constructor from Flipper::Api::Action
Instance Method Details
#post ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/flipper/api/v1/actions/import.rb', line 12 def post # Rack 3 changed the requirement to rewind the body, so we can't assume it is rewound, # so rewind before under Rack 3+ and after under Rack 2. request.body.rewind if Gem::Version.new(Rack.release) >= Gem::Version.new('3.0.0') body = request.body.read request.body.rewind if Gem::Version.new(Rack.release) < Gem::Version.new('3.0.0') export = Flipper::Exporters::Json::Export.new(contents: body) flipper.import(export) json_response({}, 204) rescue Flipper::Exporters::Json::InvalidError json_error_response(:import_invalid) end |