Add json() helper
This commit is contained in:
parent
dfe9b1a90f
commit
9f222725d1
10
app.rb
10
app.rb
@ -209,6 +209,16 @@ before do
|
|||||||
request.session_options[:skip] = !request.path_info.start_with?("/session")
|
request.session_options[:skip] = !request.path_info.start_with?("/session")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
helpers do
|
||||||
|
def json(obj, opts: nil, pretty: false)
|
||||||
|
if pretty
|
||||||
|
JSON.pretty_generate obj, opts:
|
||||||
|
else
|
||||||
|
JSON.generate(obj, opts:)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get "/" do
|
get "/" do
|
||||||
"hello there!\n"
|
"hello there!\n"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user