Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,41 @@
Async::HTTP::Endpoint.parse("#{scheme}://0.0.0.0:#{port}").with(**options)
end
end

unless ENV["SERVICE_DIRECT_PORT"].to_s.empty?
service "#{hostname}-http" do
include Falcon::Environment::Rack

preload "preload.rb"

count 1

protocol { Async::HTTP::Protocol::HTTP11 }
scheme { "http" }

rack_app do
app = super()
allowed_paths = %w[/api/reporting/ /up]

->(env) do
if allowed_paths.any? { |path| env["PATH_INFO"].start_with?(path) }
app.call(env)
else
[
403,
{ "content-type" => "text/plain" },
[
"Path #{env["PATH_INFO"]} is not allowed. Allowed paths: #{allowed_paths.join(", ")}"
]
]
end
end
end

endpoint do
Async::HTTP::Endpoint.parse(
"http://0.0.0.0:#{ENV["SERVICE_DIRECT_PORT"]}"
).with(protocol: protocol)
end
end
end
Loading