add route to test chunked encoding
This commit is contained in:
parent
86ba2e6c1a
commit
b2e4fcbce1
7
app.rb
7
app.rb
@ -427,11 +427,14 @@ route :delete, :get, :patch, :post, :put, "/status/:code" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
get "/chunked/:delay" do
|
get "/chunked/:delay" do
|
||||||
|
content_type "application/x-ndjson"
|
||||||
|
|
||||||
delay = Float(params[:delay])
|
delay = Float(params[:delay])
|
||||||
stream do |out|
|
stream do |out|
|
||||||
out << "Hello, world!\n"
|
30.times do |i|
|
||||||
|
out << jsonify({id: i, message: i % 2 == 0 ? "tick" : "tock"})
|
||||||
sleep delay
|
sleep delay
|
||||||
out << "Hello, world!\n"
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user