Skip to content

Commit

Permalink
More logging in Proxy middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 26, 2024
1 parent b364b30 commit fc27894
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/falcon/middleware/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
require 'protocol/http/headers'
require 'protocol/http/middleware'

require 'console/event/failure'

module Falcon
module Middleware
# A static middleware which always returns a 400 bad request response.
Expand Down Expand Up @@ -95,7 +97,7 @@ def prepare_headers(headers)
def prepare_request(request, host)
forwarded = []

Console.logger.debug(self) do |buffer|
Console.debug(self) do |buffer|
buffer.puts "Request authority: #{request.authority}"
buffer.puts "Host authority: #{host.authority}"
buffer.puts "Request: #{request.method} #{request.path} #{request.version}"
Expand Down Expand Up @@ -136,12 +138,13 @@ def call(request)

client = connect(host.endpoint)

Console.debug(self, "Sending request...", host: host, request: request, count: @count)
client.call(request)
else
super
end
rescue => error
Console.error(self, error)
Console::Event::Failure.for(error).emit(self)
return Protocol::HTTP::Response[502, {'content-type' => 'text/plain'}, [error.class.name]]
end
end
Expand Down

0 comments on commit fc27894

Please sign in to comment.