class Protocol::HTTP::Middleware

You do not need to use the Middleware class to implement middleware. You can implement the interface directly.
The call method is called for each request. The close method is called when the server is shutting down.
- ‘close()`
- `call(request)` -> `response`
A middleware instance generally needs to respond to two methods:
The middleware interface provides a convenient wrapper for implementing HTTP middleware.

def self.build(&block)

Build a middleware application using the given block.
def self.build(&block)
	builder = Builder.new
	
	if block_given?
		if block.arity == 0
			builder.instance_exec(&block)
		else
			yield builder
		end
	end
	
	return builder.to_app
end

def self.for(&block)

@returns [Middleware] The middleware delegate.
@parameter block [Proc] The block to convert to a middleware delegate.

Convert a block to a middleware delegate.
def self.for(&block)
	# Add a close method to the block.
	def block.close
	end
	
	return self.new(block)
end

def call(request)

Call the middleware with the given request. Invokes the call method on the delegate.
def call(request)
	@delegate.call(request)
end

def close

Close the middleware. Invokes the close method on the delegate.
def close
	@delegate.close
end

def initialize(delegate)

@parameter delegate [Object] The delegate object. A delegate is used for passing along requests that are not handled by *this* middleware.

Initialize the middleware with the given delegate.
def initialize(delegate)
	@delegate = delegate
end