Class: Falcon::Server

Inherits:
Async::HTTP::Server
  • Object
show all
Defined in:
lib/falcon/server.rb

Overview

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

Class Method Summary collapse

Class Method Details

.middleware(rack_app, verbose: false, cache: true) ⇒ Object

Wrap a rack application into a middleware suitable the server.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/falcon/server.rb', line 42

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 Adapters::Rewindable
		use Adapters::Rack
		
		run rack_app
	end
end