Last active
August 29, 2015 14:15
-
-
Save brandonmwest/573dc65100677dc44306 to your computer and use it in GitHub Desktop.
Log a JSON payload in Sinatra
This file contains hidden or 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
post '/event' do | |
status 204 #successful request with no body content | |
request.body.rewind | |
request_payload = JSON.parse(request.body.read) | |
#append the payload to a file | |
File.open("events.txt", "a") do |f| | |
f.puts(request_payload) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment