Move text/plain routes to /_cat prefix
All checks were successful
Gitea Actions Demo / lint (push) Successful in 1m23s
Gitea Actions Demo / test (push) Successful in 1m22s
Gitea Actions Demo / release-image (push) Successful in 1m6s

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