From 88e24c688b6401fe62359138c5dfe00e731786ba Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Mon, 8 Jul 2024 10:07:34 -0500 Subject: [PATCH] Move text/plain routes to `/_cat` prefix --- app.rb | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) 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