Sha256: 017f82715f9b101905fd356e4a39ae68e09cbb4091fc11312700df8ce3d00e09

Contents?: true

Size: 753 Bytes

Versions: 5

Compression:

Stored size: 753 Bytes

Contents

$LOAD_PATH.unshift(__dir__)
require 'middleware/logging'
require 'middleware/transaction_id'
require 'middleware/error_handling'
require 'middleware/forward_proxies'
require 'middleware/reverse_proxy'
require 'rack/ssl-enforcer'
require 'rack/fiber_pool'

class SiteHub
  module Middleware
    def middlewares
      @middleware ||= []
    end

    def middleware?
      !middlewares.empty?
    end

    def use(middleware_clazz, *args, &block)
      middlewares << [middleware_clazz, args, block]
    end

    def apply_middleware(forward_proxy)
      middlewares.reverse.inject(forward_proxy) do |app, middleware_def|
        middleware, args, block = *middleware_def
        middleware.new(app, *args, &(block || proc {}))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sitehub-0.4.10 lib/sitehub/middleware.rb
sitehub-0.4.9 lib/sitehub/middleware.rb
sitehub-0.4.8 lib/sitehub/middleware.rb
sitehub-0.4.7 lib/sitehub/middleware.rb
sitehub-0.4.6 lib/sitehub/middleware.rb