Created
February 6, 2018 07:13
-
-
Save et/992faa6cf77d4199777da43f7abbf883 to your computer and use it in GitHub Desktop.
With POST endpoints
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
require 'json' | |
require 'sinatra' | |
class App < Sinatra::Base | |
get '/event' do | |
hub_challenge = params['hub.challenge'] | |
content_type :json | |
{ 'hub.challenge' => hub_challenge }.to_json | |
end | |
post '/event' do | |
status 200 | |
request.body.rewind | |
request_payload = JSON.parse(request.body.read) | |
p request_payload | |
File.open('events.txt', 'a') do |f| | |
f.puts(request_payload) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment