Sha256: fd634093291f719bb286e5068299a60ba775e8128f82923c7014c43d726e8ba8

Contents?: true

Size: 1.06 KB

Versions: 58

Compression:

Stored size: 1.06 KB

Contents

module Scrivito
  #
  # This module lets you change the URL of a binary CMS object for the purpose of
  # fetching the binary data from a different location (e.g. via a proxy or from a mirror).
  #
  #
  # @api public
  #
  module BinaryRewrite
    def self.call(request, url)
      change_url_callback = request.env["SCRIVITO_BINARY_URL_CALLBACK"]
      url = change_url_callback.call(url) if change_url_callback
      url
    end
    #
    # You can, for example, have the URLs of images, etc., point to your desired
    # domain instead of to the CDN Scrivito uses.
    #
    # @api public
    #
    # @param request [ActionDispatch::Request]
    # @param block [Proc] block change default CDN url of current binary obj
    #
    # @example
    #   Scrivito::BinaryRewrite.enable_for(request) do |binary_url|
    #     binary_url.sub(
    #       "https://scrivito-public-cdn.s3-eu-west-1.amazonaws.com/",
    #       "https://my.reverse.proxy.com/")
    #   end
    #
    def self.enable_for(request, &block)
      request.env["SCRIVITO_BINARY_URL_CALLBACK"] = block
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
scrivito_sdk-1.6.0.rc4 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.6.0.rc3 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.3 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.6.0.rc2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.3.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.6.0.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.2.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.1.rc2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.1.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.0 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.0.rc2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.5.0.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.1.rc1 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.0 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.0.rc2 lib/scrivito/binary_rewrite.rb
scrivito_sdk-1.4.0.rc1 lib/scrivito/binary_rewrite.rb