Class: Protocol::HTTP::Middleware

Inherits:
Methods
  • Object
show all
Defined in:
lib/protocol/http/middleware.rb,
lib/protocol/http/middleware/builder.rb

Direct Known Subclasses

AcceptEncoding, ContentEncoding

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Methods

each, valid?

Constructor Details

#initialize(delegate) ⇒ Middleware

Returns a new instance of Middleware.


39
40
41
# File 'lib/protocol/http/middleware.rb', line 39

def initialize(delegate)
	@delegate = delegate
end

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate.


43
44
45
# File 'lib/protocol/http/middleware.rb', line 43

def delegate
  @delegate
end

Class Method Details

.build(&block) ⇒ Object


58
59
60
61
62
63
64
# File 'lib/protocol/http/middleware/builder.rb', line 58

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.


32
33
34
35
36
37
# File 'lib/protocol/http/middleware.rb', line 32

def self.for(&block)
	def block.close
	end
	
	return self.new(block)
end

Instance Method Details

#call(request) ⇒ Object


49
50
51
# File 'lib/protocol/http/middleware.rb', line 49

def call(request)
	@delegate.call(request)
end

#closeObject


45
46
47
# File 'lib/protocol/http/middleware.rb', line 45

def close
	@delegate.close
end