Skip to content

Instantly share code, notes, and snippets.

@fender21
Created December 2, 2011 00:07
Show Gist options
  • Save fender21/1420876 to your computer and use it in GitHub Desktop.
Save fender21/1420876 to your computer and use it in GitHub Desktop.
Better way to route?
post :index do
#determine the querystring which is NOT restful and route to approriate view
#URL looks like this http://localhost/app?create&id=10
url = env['REQUEST_URI']
uri = Addressable::URI.parse(url).query_values.to_hash
#Provide Server Info text per spec
if uri.has_key?("create")
tmp_dir = File.join(Padrino.root, 'tmp')
raw_data = request.body.read.force_encoding('UTF-8')
file_name = File.join(tmp_dir, params[:docId])
# #save out file
File.open("#{file_name}.pdf", 'w') do |f|
f.write(raw_data)
status 200
end
end
# File.open("#{file_name}-params.txt", 'w') do |f|
# f.write(params.to_s)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment