Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonmwest/573dc65100677dc44306 to your computer and use it in GitHub Desktop.
Save brandonmwest/573dc65100677dc44306 to your computer and use it in GitHub Desktop.
Log a JSON payload in Sinatra
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