Class: Protocol::HTTP::Middleware
- Defined in:
- lib/protocol/http/middleware.rb,
lib/protocol/http/middleware/builder.rb
Direct Known Subclasses
Defined Under Namespace
Modules: HelloWorld, NotFound, Okay Classes: Builder
Constant Summary
Constants inherited from Methods
Protocol::HTTP::Methods::CONNECT, Protocol::HTTP::Methods::DELETE, Protocol::HTTP::Methods::GET, Protocol::HTTP::Methods::HEAD, Protocol::HTTP::Methods::LINK, Protocol::HTTP::Methods::OPTIONS, Protocol::HTTP::Methods::PATCH, Protocol::HTTP::Methods::POST, Protocol::HTTP::Methods::PUT, Protocol::HTTP::Methods::TRACE, Protocol::HTTP::Methods::UNLINK
Instance Attribute Summary collapse
-
#delegate ⇒ Object
readonly
Returns the value of attribute delegate.
Class Method Summary collapse
- .build(&block) ⇒ Object
-
.for(&block) ⇒ Object
Convert a block to a middleware delegate.
Instance Method Summary collapse
- #call(request) ⇒ Object
- #close ⇒ Object
-
#initialize(delegate) ⇒ Middleware
constructor
A new instance of Middleware.
Methods inherited from Methods
Constructor Details
#initialize(delegate) ⇒ Middleware
Returns a new instance of Middleware.
22 23 24 |
# File 'lib/protocol/http/middleware.rb', line 22 def initialize(delegate) @delegate = delegate end |
Instance Attribute Details
#delegate ⇒ Object (readonly)
Returns the value of attribute delegate.
26 27 28 |
# File 'lib/protocol/http/middleware.rb', line 26 def delegate @delegate end |
Class Method Details
.build(&block) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/protocol/http/middleware/builder.rb', line 32 def self.build(&block) builder = Builder.new builder.instance_eval(&block) return builder.to_app end |
.for(&block) ⇒ Object
Convert a block to a middleware delegate.
15 16 17 18 19 20 |
# File 'lib/protocol/http/middleware.rb', line 15 def self.for(&block) def block.close end return self.new(block) end |
Instance Method Details
#call(request) ⇒ Object
32 33 34 |
# File 'lib/protocol/http/middleware.rb', line 32 def call(request) @delegate.call(request) end |
#close ⇒ Object
28 29 30 |
# File 'lib/protocol/http/middleware.rb', line 28 def close @delegate.close end |