Class: Async::HTTP::Middleware::Builder
- Inherits:
-
Object
- Object
- Async::HTTP::Middleware::Builder
- Defined in:
- lib/async/http/middleware/builder.rb
Instance Method Summary collapse
-
#initialize(default_app = NotFound, &block) ⇒ Builder
constructor
A new instance of Builder.
- #run(app) ⇒ Object
- #to_app ⇒ Object
- #use(middleware, *args, &block) ⇒ Object
Constructor Details
Instance Method Details
#run(app) ⇒ Object
47 48 49 |
# File 'lib/async/http/middleware/builder.rb', line 47 def run(app) @app = app end |
#to_app ⇒ Object
51 52 53 |
# File 'lib/async/http/middleware/builder.rb', line 51 def to_app @use.reverse.inject(@app) {|app, use| use.call(app).freeze} end |
#use(middleware, *args, &block) ⇒ Object
43 44 45 |
# File 'lib/async/http/middleware/builder.rb', line 43 def use(middleware, *args, &block) @use << proc {|app| middleware.new(app, *args, &block)} end |