class Falcon::Configuration

def initialize(verbose = false)

def initialize(verbose = false)
	@environments = {}
	@verbose = verbose
	
	add(:ssl) do
		ssl_session_id {"falcon"}
	end
	
	add(:host, :ssl) do
		ssl_certificate_path {File.expand_path("ssl/certificate.pem", root)}
		ssl_certificate {OpenSSL::X509::Certificate.new(File.read(ssl_certificate_path))}
		
		ssl_private_key_path {File.expand_path("ssl/private.key", root)}
		ssl_private_key {OpenSSL::PKey::RSA.new(File.read(ssl_private_key_path))}
		
		ssl_context do
			OpenSSL::SSL::SSLContext.new.tap do |context|
				context.cert = ssl_certificate
				context.key = ssl_private_key
				
				context.session_id_context = ssl_session_id
				
				context.set_params
				
				context.setup
			end
		end
	end
	
	add(:lets_encrypt, :ssl) do
		lets_encrypt_root '/etc/letsencrypt/live'
		ssl_certificate_path {File.join(lets_encrypt_root, authority, "fullchain.pem")}
		ssl_private_key_path {File.join(lets_encrypt_root, authority, "privkey.pem")}
	end
	
	add(:self_signed, :ssl) do
		ssl_context do
			contexts = Localhost::Authority.fetch(authority)
			
			contexts.server_context.tap do |context|
				context.alpn_select_cb = lambda do |protocols|
					if protocols.include? "h2"
						return "h2"
					elsif protocols.include? "http/1.1"
						return "http/1.1"
					elsif protocols.include? "http/1.0"
						return "http/1.0"
					else
						return nil
					end
				end
				
				context.session_id_context = "falcon"
			end
		end
	end
	
	add(:proxy, :host) do
		endpoint {::Async::HTTP::URLEndpoint.parse(url)}
	end
	
	add(:rack, :host) do
		config_path {::File.expand_path("config.ru", root)}
		
		middleware do
			::Falcon::Server.middleware(
				::Rack::Builder.parse_file(config_path).first, verbose: verbose
			)
		end
		
		authority 'localhost'
		scheme 'https'
		protocol {::Async::HTTP::Protocol::HTTP2}
		ipc_path {::File.expand_path("server.ipc", root)}
		
		endpoint {ProxyEndpoint.unix(ipc_path, protocol: protocol, scheme: scheme, authority: authority)}
		
		bound_endpoint do
			Async::Reactor.run do
				Async::IO::SharedEndpoint.bound(endpoint)
			end.wait
		end
		
		server do
			::Falcon::Server.new(middleware, bound_endpoint, protocol, scheme)
		end
	end
end