Created
March 3, 2014 20:22
-
-
Save joshwlewis/9333791 to your computer and use it in GitHub Desktop.
Get request json for Sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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