Sha256: 5169332f466925392ae8d0133930aa84a25223134b368b31eec0746c6658d628

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

module Lotus
  # Rack middleware stack for an application
  #
  # @since 0.1.0
  # @api private
  class Middleware
    # Instantiate a middleware stack
    #
    # @param application [Lotus::Application] the application
    #
    # @return [Lotus::Middleware] the new stack
    #
    # @since 0.1.0
    # @api private
    #
    # @see Lotus::Configuration
    # @see http://rdoc.info/gems/rack/Rack/Builder
    def initialize(application)
      configuration = application.configuration
      routes        = application.routes

      @builder = ::Rack::Builder.new
      @builder.use Rack::Static,
        urls: configuration.assets.entries,
        root: configuration.assets
      @builder.run routes
    end

    # Process a request.
    # This method makes the middleware stack compatible with the Rack protocol.
    #
    # @param env [Hash] a Rack env
    #
    # @return [Array] a serialized Rack response
    #
    # @since 0.1.0
    # @api private
    def call(env)
      @builder.call(env)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lotusrb-0.1.0 lib/lotus/middleware.rb