add routes to dump configuration

This commit is contained in:
Ryan Cavicchioni 2025-03-09 15:36:07 -05:00
parent fde1dd14b5
commit 3a78bf5d03
Signed by: ryanc
SSH Key Fingerprint: SHA256:KbXiwUnZnHFwFtt3Bytd+F3FN9pPHn1Z1cxMIE1TPbg

21
app.rb
View File

@ -375,6 +375,12 @@ get "/cookies" do
jsonify response.headers
end
get "/config", provides: "json" do
pretty = params.key? :pretty
jsonify config.as_json, pretty:
end
get "/_cat/headers" do
stream do |out|
req_headers.each do |k, v|
@ -399,6 +405,21 @@ get "/_cat/cookies" do
end
end
get "/_cat/config" do
stream do |out|
config.instance_variables.each do |k|
k = k.to_s.delete_prefix "@"
begin
v = config.send(k)
rescue NoMethodError
next
end
out << "#{k}(#{v.to_s.length})=#{v}\n"
end
end
end
route :delete, :get, :patch, :post, :put, "/status/:code" do
# hello
code = Integer(params[:code])