Sha256: 7bb5d8fe00a592f630ebede33515fc09e75d3cb97c64f4ebcfb66d709574ae23
Contents?: true
Size: 892 Bytes
Versions: 5
Compression:
Stored size: 892 Bytes
Contents
module Scrivito 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 {Scrivito::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
5 entries across 5 versions & 1 rubygems