Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions frameworks/rails/app/controllers/benchmark_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,8 @@ def json_endpoint
d.merge(total: d[:price] * d[:quantity] * m)
end

result = JSON.generate(items: items, count: items.length)

if accept_encodings = request.headers['Accept-Encoding']
types = accept_encodings.split(',').map(&:strip)
if types.include? 'gzip'
sio = StringIO.new
gz = Zlib::GzipWriter.new(sio, 1)
gz.write(result)
gz.close
response.headers['content-type'] = 'application/json'
response.headers['content-encoding'] = 'gzip'
send_data sio.string, disposition: :inline
else
render json: result
end
else
render json: result
end

render json: JSON.generate(items: items, count: items.length)
end

def async_db
Expand Down
Loading