Sha256: 77b15d96bc9e3bcbc8b485a3a312bf4568471a1c1cd96ee9030dde5189527529

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

$LOAD_PATH.unshift(__dir__)
require 'middleware/logging'
require 'middleware/transaction_id'
require 'middleware/error_handling'
require 'middleware/routes'
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

4 entries across 4 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha5 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha4 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha3 lib/sitehub/middleware.rb
sitehub-0.5.0.alpha2 lib/sitehub/middleware.rb