Sha256: 3c06167f0cd3752db8b880693ed2037caa35d1e5f6df479bf78f9f8c0b8e7374

Contents?: true

Size: 1.38 KB

Versions: 25

Compression:

Stored size: 1.38 KB

Contents

require 'routemaster/middleware/root_post_only'
require 'routemaster/middleware/authenticate'
require 'routemaster/middleware/parse'
require 'routemaster/middleware/siphon'
require 'routemaster/middleware/expire_cache'
require 'routemaster/middleware/payload_filter'
require 'routemaster/middleware/filter'
require 'routemaster/drain/terminator'
require 'rack/builder'
require 'delegate'

module Routemaster
  module Drain
    # Rack application which authenticates, parses, filters duplicates in this request
    # and invalidates the cache for all updated or new items.
    #
    # See the various corresponding middleware for details on operation:
    # {Middleware::RootPostOnly}, {Middleware::Authenticate},
    # {Middleware::Parse}, {Middleware::ExpireCache} and {Terminator}.
    class CacheBusting
      extend Forwardable

      def initialize(options = {})
        @terminator = terminator = Terminator.new
        @app = ::Rack::Builder.new do
          use Middleware::RootPostOnly
          use Middleware::Authenticate, options
          use Middleware::Parse
          use Middleware::Siphon,       options
          use Middleware::Filter, { filter: Routemaster::Middleware::PayloadFilter.new }.merge(options)
          use Middleware::ExpireCache
          run terminator
        end
      end

      delegate :call => :@app
      delegate [:on, :subscribe] => :@terminator
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
routemaster-drain-3.0.0 lib/routemaster/drain/cache_busting.rb
routemaster-drain-2.5.4 lib/routemaster/drain/cache_busting.rb
routemaster-drain-2.5.3 lib/routemaster/drain/cache_busting.rb
routemaster-drain-2.5.2 lib/routemaster/drain/cache_busting.rb
routemaster-drain-2.5.1 lib/routemaster/drain/cache_busting.rb