-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
module Falcon | ||
module Environment | ||
# This module provides a common interface for configuring the Falcon application. | ||
# @todo Reuse this for proxy and redirect services. | ||
module Configured | ||
# All the falcon application configuration paths. | ||
# @returns [Array(String)] Paths to the falcon application configuration files. | ||
def configuration_paths | ||
["/srv/http/*/falcon.rb"] | ||
end | ||
|
||
# All the falcon application configuration paths, with wildcards expanded. | ||
def resolved_configuration_paths | ||
configuration_paths.flat_map do |path| | ||
Dir.glob(path) | ||
end.uniq | ||
end | ||
|
||
def configuration | ||
::Async::Service::Configuration.load(resolved_configuration_paths) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2024, by Samuel Williams. | ||
|
||
require_relative 'configured' | ||
|
||
require_relative '../service/virtual' | ||
|
||
module Falcon | ||
module Environment | ||
module Virtual | ||
include Configured | ||
|
||
# The service class to use for the virtual host. | ||
# @returns [Class] | ||
def service_class | ||
Service::Virtual | ||
end | ||
|
||
def name | ||
service_class.name | ||
end | ||
|
||
# The URI to bind the `HTTPS` -> `falcon host` proxy. | ||
def bind_secure | ||
"https://[::]:443" | ||
end | ||
|
||
# The URI to bind the `HTTP` -> `HTTPS` redirector. | ||
def bind_insecure | ||
"http://[::]:80" | ||
end | ||
|
||
# The connection timeout to use for incoming connections. | ||
def timeout | ||
10.0 | ||
end | ||
|
||
# The path to the falcon executable from this gem. | ||
# @returns [String] | ||
def falcon_path | ||
File.expand_path("../../../bin/falcon", __dir__) | ||
end | ||
|
||
# # The insecure endpoint for connecting to the {Redirect} instance. | ||
# def insecure_endpoint(**options) | ||
# Async::HTTP::Endpoint.parse(bind_insecure, **options) | ||
# end | ||
|
||
# # The secure endpoint for connecting to the {Proxy} instance. | ||
# def secure_endpoint(**options) | ||
# Async::HTTP::Endpoint.parse(bind_secure, **options) | ||
# end | ||
|
||
# # An endpoint suitable for connecting to the specified hostname. | ||
# def host_endpoint(hostname, **options) | ||
# endpoint = secure_endpoint(**options) | ||
|
||
# url = URI.parse(bind_secure) | ||
# url.hostname = hostname | ||
|
||
# return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname) | ||
# end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters