Receive webhooks and publish their contents to RabbitMQ.
This uses the Lapine gem for publishing messages. See Lapine for how to consume messages.
This application includes a Sinatra app that listens on paths matching different Webhook integrations. When a hook is received, its content is published to a RabbitMQ topic exchange with a routing key matching the type of webhook.
See Configuration for how to configure the RabbitMQ connection and exchange used by Webhook.
A /stripe endpoint is registered that listens for POST actions with JSON content.
The type field of the JSON is used to construct the message routing key, prepended with
stripe. For instance, if a charge.failed webhook is received, the message published to
RabbitMQ will have a routing key of stripe.charge.failed.
The full content of the webhook will be published as the message body.
Running tests:
bundle
bundle exec rake reset
bundle exec rakerake reset will symlink missing configuration files to the example files provided in
config/.
Create a publishers.yml in the config directory. This file is ignored by git.
connection:
host: '127.0.0.1'
port: 5672
ssl: false
vhost: '/'
username: 'guest'
password: 'guest'
exchange: my.topicThis has a hard assumption that the exchange is a topic exchange configured with
durable: true.
Unicorn can be configured via the following environment variables:
WORKER_PROCESSESWORKING_DIRECTORYUNICORN_TIMEOUTUNICORN_PIDFILEUNICORN_STDERRUNICORN_STDOUT
bundle exec unicorn -c config/unicorn.rb -p %{config/port} config.ruPlease use a copy/truncate strategy for log rotation. Webhook does not include any facility for reopening file descriptors were the logfiles to be moved and reopened.