Add JSON endpoint for /env

This commit is contained in:
Ryan Cavicchioni 2024-07-04 02:01:38 -05:00
parent 6802c59f1d
commit c8372cec1c
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

6
app.rb
View File

@ -210,6 +210,12 @@ get "/" do
"hello there!\n" "hello there!\n"
end end
get "/env", provides: "json" do
return JSON.pretty_generate ENV.sort.to_h if params.key? "pretty"
JSON.generate ENV.sort.to_h
end
get "/env" do get "/env" do
stream do |out| stream do |out|
ENV.sort.each do |k, v| ENV.sort.each do |k, v|