Move text/plain routes to /_cat prefix

This commit is contained in:
Ryan Cavicchioni 2024-07-08 10:07:34 -05:00
parent ca7d22374d
commit 88e24c688b
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

35
app.rb
View File

@ -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