Class: Falcon::Controller::Redirect

Inherits:
Serve
  • Object
show all
Defined in:
lib/falcon/controller/redirect.rb

Overview

A controller for redirecting requests.

Instance Method Summary collapse

Methods inherited from Serve

#create_container, #setup, #stop

Constructor Details

#initialize(command, **options) ⇒ Redirect

Initialize the redirect controller.



35
36
37
38
39
# File 'lib/falcon/controller/redirect.rb', line 35

def initialize(command, **options)
	super(command, **options)
	
	@hosts = {}
end

Instance Method Details

#endpointObject

The endpoint the server will bind to.



52
53
54
55
56
# File 'lib/falcon/controller/redirect.rb', line 52

def endpoint
	@command.endpoint.with(
		reuse_address: true,
	)
end

#load_appObject

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



42
43
44
# File 'lib/falcon/controller/redirect.rb', line 42

def load_app
	return Middleware::Redirect.new(Middleware::NotFound, @hosts, @command.redirect_endpoint)
end

#nameObject

The name of the controller which is used for the process title.



47
48
49
# File 'lib/falcon/controller/redirect.rb', line 47

def name
	"Falcon Redirect Server"
end

#startObject

Builds a map of host redirections.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/falcon/controller/redirect.rb', line 59

def start
	configuration = @command.configuration
	
	services = Services.new(configuration)
	
	@hosts = {}
	
	services.each do |service|
		if service.is_a?(Service::Proxy)
			@hosts[service.authority] = service
		end
	end
	
	super
end