Class: Hanami::Configuration::Middleware Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/configuration/middleware.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Middleware configuration

Since:

  • 1.2.0

Instance Method Summary collapse

Constructor Details

#initializeMiddleware

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Middleware.

Since:

  • 1.2.0



11
12
13
# File 'lib/hanami/configuration/middleware.rb', line 11

def initialize
  @middleware = Concurrent::Array.new
end

Instance Method Details

#each(&blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



35
36
37
# File 'lib/hanami/configuration/middleware.rb', line 35

def each(&blk)
  @middleware.each(&blk)
end

#use(middleware, *args, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Use a Rack middleware

Examples:

# config/environment.rb
# ...
Hanami.configure do
  middleware.use MyRackMiddleware
end

Parameters:

  • middleware (#call)

    a Rack middleware

  • args (Array<Object>)

    an optional set of options

  • blk (Proc)

    an optional block to pass to the middleware

Since:

  • 1.2.0



29
30
31
# File 'lib/hanami/configuration/middleware.rb', line 29

def use(middleware, *args, &blk)
  @middleware.push([middleware, args, blk])
end