Module: Falcon::Environment::Server

Includes:
Async::Service::ManagedEnvironment
Included in:
Application, Proxy, Redirect
Defined in:
lib/falcon/environment/server.rb

Overview

Provides an environment for hosting a web application that uses a Falcon server.

Instance Method Summary collapse

Instance Method Details

#authorityObject

The server authority. Defaults to the server name.



26
27
28
# File 'lib/falcon/environment/server.rb', line 26

def authority
  self.name
end

#cacheObject

Whether to enable the HTTP cache for this server.



60
61
62
# File 'lib/falcon/environment/server.rb', line 60

def cache
  false
end

#client_endpointObject

A client endpoint that can be used to connect to the server.



66
67
68
# File 'lib/falcon/environment/server.rb', line 66

def client_endpoint
  ::Async::HTTP::Endpoint.parse(url)
end

#endpointObject

The upstream endpoint that will handle incoming requests.



50
51
52
# File 'lib/falcon/environment/server.rb', line 50

def endpoint
  ::Async::HTTP::Endpoint.parse(url).with(**endpoint_options)
end

#endpoint_optionsObject

Options to use when creating the endpoint.



41
42
43
44
45
46
# File 'lib/falcon/environment/server.rb', line 41

def endpoint_options
  {
    reuse_address: true,
    timeout: self.timeout,
  }
end

#make_server(endpoint) ⇒ Object

Make a server instance using the given endpoint. The endpoint may be a bound endpoint, so we take care to specify the protocol and scheme as per the original endpoint.



74
75
76
# File 'lib/falcon/environment/server.rb', line 74

def make_server(endpoint)
  Falcon::Server.new(self.middleware, endpoint, protocol: self.endpoint.protocol, scheme: self.endpoint.scheme)
end

#service_classObject

The service class to use for the proxy.



20
21
22
# File 'lib/falcon/environment/server.rb', line 20

def service_class
  Service::Server
end

#timeoutObject

The timeout used for client connections.



36
37
38
# File 'lib/falcon/environment/server.rb', line 36

def timeout
  nil
end

#urlObject

The host that this server will receive connections for.



31
32
33
# File 'lib/falcon/environment/server.rb', line 31

def url
  "http://[::]:9292"
end

#verboseObject

Whether to enable verbose logging.



55
56
57
# File 'lib/falcon/environment/server.rb', line 55

def verbose
  false
end