Sha256: b3647e901d4de82a189edc800d954ffb3a81231160341f469159d542b7d04947

Contents?: true

Size: 904 Bytes

Versions: 9

Compression:

Stored size: 904 Bytes

Contents

module RailsConnector

class WebserviceController < ActionController::Base
  rescue_from ClientError do |exception|
    render json: {error: exception.message}, status: exception.http_code
  end

  before_filter :merge_correctly_parsed_json_params
  before_filter :authorize

  private

  def authorize
    unless allow_access?
      render text: 'Forbidden', status: 403
    end
  end

  # If +true+, allow access to ObjsController, else deny access.
  # See {RailsConnector::Configuration.editing_auth} for details.
  # @return [Bool]
  def allow_access?
    Configuration.editing_auth_callback.call(request.env)
  end

  # Workaround for https://github.com/rails/rails/issues/8832
  def merge_correctly_parsed_json_params
    if request.format.json?
      body = request.body.read
      request.body.rewind
      params.merge!(ActiveSupport::JSON.decode(body)) if body.present?
    end
  end
end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
infopark_cloud_connector-7.1.0 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-7.0.2 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-7.0.1 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-7.0.0 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-6.9.5 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-6.9.4 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-6.9.3.1.36404185 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-6.9.2.1.125136549 app/controllers/rails_connector/webservice_controller.rb
infopark_cloud_connector-6.9.1.3.22208381 app/controllers/rails_connector/webservice_controller.rb