FalconSourceFalconServer

class Server

A server listening on a specific endpoint, hosting a specific middleware.

Definitions

def self.middleware(rack_app, verbose: false, cache: true)

Wrap a rack application into a middleware suitable the server.

Signature

parameter rack_app Proc | Object

A rack application/middleware.

parameter verbose Boolean

Whether to add the Verbose middleware.

parameter cache Boolean

Whether to add the Async::HTTP::Cache middleware.

Implementation

def self.middleware(rack_app, verbose: false, cache: true)
	::Protocol::HTTP::Middleware.build do
		if verbose
			use Middleware::Verbose
		end
		
		if cache
			use Async::HTTP::Cache::General
		end
		
		use ::Protocol::HTTP::ContentEncoding
		use ::Protocol::Rack::Adapter
		
		run rack_app
	end
end