Module: Falcon::Environment::Redirect

Includes:
Server
Defined in:
lib/falcon/environment/redirect.rb

Overview

Provides an environment for redirecting insecure web traffic to a secure endpoint.

Instance Method Summary collapse

Methods included from Server

#authority, #cache, #client_endpoint, #endpoint, #endpoint_options, #make_server, #service_class, #timeout, #url, #verbose

Instance Method Details

#environmentsObject

The services we will redirect to.



30
31
32
# File 'lib/falcon/environment/redirect.rb', line 30

def environments
	[]
end

#hostsObject

Build a hash of host authorities to their evaluators for redirect matching.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/falcon/environment/redirect.rb', line 36

def hosts
	hosts = {}
	
	environments.each do |environment|
		evaluator = environment.evaluator
		
		if environment.implements?(Falcon::Environment::Application)
			Console.info(self){"Redirecting #{self.url} to #{evaluator.authority}"}
			hosts[evaluator.authority] = evaluator
		end
	end
	
	return hosts
end

#middlewareObject

Load the Middleware::Redirect application with the specified hosts.



52
53
54
# File 'lib/falcon/environment/redirect.rb', line 52

def middleware
	Middleware::Redirect.new(Middleware::NotFound, hosts, redirect_endpoint)
end

#redirect_endpointObject

Parse the redirect URL into an endpoint.



24
25
26
# File 'lib/falcon/environment/redirect.rb', line 24

def redirect_endpoint
	Async::HTTP::Endpoint.parse(redirect_url)
end

#redirect_urlObject

The URL template to redirect to.



18
19
20
# File 'lib/falcon/environment/redirect.rb', line 18

def redirect_url
	"https://[::]:443"
end