Sha256: bbe3dd714a968f00136faba5a4173efbbb4b55262a6f10c856b8c7d98c4afda6

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

$LOAD_PATH.unshift(__dir__)
require 'middleware/logging'
require 'middleware/transaction_id'
require 'middleware/error_handling'
require 'middleware/candidate_route_mappings'
require 'middleware/reverse_proxy'
require 'middleware/config_loader'
require 'rack/ssl-enforcer'
require 'middleware/route'
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

6 entries across 6 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha12 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha11 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha10 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha8 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha7 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha6 lib/sitehub/middleware.rb