Commit 0ee6318b authored by John E. Vincent's avatar John E. Vincent

example webhook post

parent ad98ea34
require 'sinatra'
post '/webhook' do
p request.body.read
end
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
require 'rubygems'
require 'em-hiredis'
require 'em-http-request'
EventMachine.run do
# Passing messages...like a boss
@channel = EventMachine::Channel.new
r = EventMachine::Hiredis::Client.connect
r.psubscribe("noah.*")
r.on(:pmessage) do |pattern, event, message|
puts "Got message for #{event}"
@channel.push "#{message}"
end
request = EventMachine::HttpRequest.new('http://localhost:4567/webhook')
sub = @channel.subscribe { |msg|
http = request.post(:body => msg, :head => {"Content-Type" => "application/json"})
}
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment