lib/jets/mega/request.rb in jets-1.2.1 vs lib/jets/mega/request.rb in jets-1.3.0

- old
+ new

@@ -2,10 +2,11 @@ require 'rack' module Jets::Mega class Request autoload :Source, 'jets/mega/request/source' + JETS_OUTPUT = "/tmp/jets-output.log" extend Memoist def initialize(event, controller) @event = event @@ -43,14 +44,24 @@ request = set_headers!(request) # Make request response = http.request(request) + puts_rack_output + { status: response.code.to_i, headers: response.each_header.to_h, body: response.body, } + end + + # Grab the rack output from the /tmp/jets-output.log and puts it back in the + # main process' stdout + def puts_rack_output + return unless File.exist?(JETS_OUTPUT) + puts IO.readlines(JETS_OUTPUT) + File.truncate(JETS_OUTPUT, 0) end def get_uri url = "http://localhost:9292#{@controller.request.path}" # local rack server unless @controller.query_parameters.empty?