Sha256: b569eca99481c057e171a4ba4d184c6aa8a6c1aba908c51c6d011cc2c1c7716e

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'routemaster/middleware/root_post_only'
require 'routemaster/middleware/authenticate'
require 'routemaster/middleware/parse'
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::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

1 entries across 1 versions & 1 rubygems

Version Path
routemaster-drain-2.5.0 lib/routemaster/drain/cache_busting.rb