Sha256: 7a3786a4efd120441863989bc111cf692853c2f83aed7ac367348d994e755dd4

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

module Scrivito
  class BinaryRedirectController < ActionController::Base
    def to_binary
      binary = BinaryParamVerifier.verify(params[:encrypted_params])
      redirect_to BinaryRewrite.call(request, binary.url), status: 301, allow_other_host: true
    rescue BinaryParamVerifier::InvalidSignature
      head :precondition_failed
    rescue TransformationSourceError => error
      case error.code
      when /transform.source.too_large/ then render_error('source_too_large')
      else render_error('source_invalid')
      end
    end

    private

    def render_error(error_name)
      redirect_to view_context.image_path("scrivito/#{error_name}.png"), allow_other_host: true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scrivito_sdk-1.18.0 app/controllers/scrivito/binary_redirect_controller.rb
scrivito_sdk-1.18.0.rc1 app/controllers/scrivito/binary_redirect_controller.rb