Skip to content

Instantly share code, notes, and snippets.

@joshwlewis
Created March 3, 2014 20:22
Show Gist options
  • Save joshwlewis/9333791 to your computer and use it in GitHub Desktop.
Save joshwlewis/9333791 to your computer and use it in GitHub Desktop.
Get request json for Sinatra
class App < Sinatra::Base
helpers do
def request_json
request.body.rewind
::JSON.parse(request.body.read)
end
end
put '/foobar' do
@data = request_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment