- Ensure you have PostgreSQL installed and running. You can do this through homebrew or by installing Postgres.app.
- Ensure you have autoenv installed. You can do this through homebrew.
- Ensure you have the Heroku toolbelt installed
- Ensure you have Go installed. You can do this through homebrew.
- Ensure your
$GOPATH
is set.
$ cd $GOPATH/src/github.com/SparkPost
$ git clone git@github.com:SparkPost/sparkies.git
$ cd sparkies
$ go build
$ heroku local web
This will start the app on port 5000.
Create a JSON file called test.json to simulate a relay webhook with the following contents:
[{
"msys": {
"relay_message": {
"friendly_from": "\"SparkPost Developers\" <devlopers@sparkpost.com>",
"msg_from": "developers@sparkpost.com",
"rcpt_to": "hello@messagesystems.com",
"webhook_id": "66177122594674207",
"content": {
"html": "<html><head><title>Yay An HTML Title!</title></head><body><h1>And the html body.</h1></body></html>",
"text": "Yay A Text Title!\nAnd the text body.",
"subject": "Super Sweet Relay Message",
"to": [
"hello@messagesystems.com"
],
"headers": [
{ "Received": "from the internet." }
],
"email_rfc822": "In case it wasn't obvious, this isn't a valid MIME message.",
"email_rfc822_is_base64": false
}
}
}
}]
Call the incoming
endpoint with the simulated relay webhook data:
$ curl -XPOST -H 'Content-Type: application/json' --data @test.json http://127.0.0.1:5000/incoming
You can launch psql and inspect the data. To see the raw incoming data:
$ psql
user=# select * from request_dump.raw_requests;
To see the processed data:
$ psql
user=# select * from request_dump.relay_messages;
To deploy the code to Heroku, ensure you are authenticated as the correct user. Then run the following commands to deploy:
$ git push heroku && git push heroku master