diff --git a/app.rb b/app.rb index b9bce59..0ffda20 100644 --- a/app.rb +++ b/app.rb @@ -204,6 +204,7 @@ end before do # content_type 'text/plain' sleep(1) while Sleep.instance.asleep? && request.path_info != "/livez/sleep" + content_type :text if request.path_info.start_with? "/_cat" end get "/" do @@ -211,19 +212,13 @@ get "/" do end get "/env", provides: "json" do + content_type :json + return JSON.pretty_generate ENV.sort.to_h if params.key? "pretty" JSON.generate ENV.sort.to_h end -get "/env" do - stream do |out| - ENV.sort.each do |k, v| - out << "#{k}=#{v}\n" - end - end -end - get "/headers", provides: "json" do h = req_headers return JSON.pretty_generate h if params.key? "pretty" @@ -231,14 +226,6 @@ get "/headers", provides: "json" do JSON.generate h end -get "/headers" do - stream do |out| - req_headers.each do |k, v| - out << "#{k}: #{v.inspect}\n" - end - end -end - get "/livez" do error 503 unless Health.instance.healthy? @@ -336,3 +323,19 @@ end get "/cookies" do json response.headers end + +get "/_cat/headers" do + stream do |out| + req_headers.each do |k, v| + out << "#{k}: #{v.inspect}\n" + end + end +end + +get "/_cat/env" do + stream do |out| + ENV.sort.each do |k, v| + out << "#{k}=#{v}\n" + end + end +end