Skip to content

Commit

Permalink
Merge pull request #3 from curtiszimmerman/https_endpoint_support
Browse files Browse the repository at this point in the history
added: HTTPS endpoint support
  • Loading branch information
mintbridge committed Feb 8, 2015
2 parents 0ec1067 + 4b6ca1a commit f8b7a4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 13 additions & 14 deletions README.md
@@ -1,7 +1,7 @@
Uptime Webhooks plugin
======================

This Uptime (https://github.com/fzaninotto/uptime) plugin notifies all configured events (up, down, paused, restarted) by sending a HTTP POST request to the given URL. The request will have a JSON payload of data from the event. Each event can have multiple hook URL's.
This Uptime (https://github.com/fzaninotto/uptime) plugin notifies all configured events (up, down, paused, restarted) by sending a HTTP POST request to the given URL. The request will have a JSON payload of data from the event. Each event can have multiple hook URLs. URLs can be plain HTTP or HTTPS.

To use the plugin, first install it using npm while in the Uptime directory:

Expand All @@ -14,22 +14,21 @@ Then to enable it, add it to the `plugins/index.js`, as follows:
```js
// in plugins/index.js
exports.init = function() {
require('webhooks').init();
require('uptime-webhooks').init();
}
```

Customize the plugin settings in the `config/production.yaml` configuration file, as in the example below:
Customize the settings in the `config/production.yaml` configuration file, adding a `webhooks` section, as in the example below:

```yaml
plugins:
webhooks:
event:
up:
- 'http://localhost:8082'
- 'http://www.example.com/do/something'
down:
- 'http://www.example.com/warn/somebody'
paused:
restarted:
dashboardUrl: 'http://localhost:8082'
webhooks:
event:
up:
- 'http://localhost:8082'
- 'https://www.example.com/do/something'
down:
- 'https://www.example.com/warn/somebody'
paused:
restarted:
dashboardUrl: 'http://localhost:8082'
```
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -24,6 +24,7 @@
*/

var http = require('http');
var https = require('https');
var url = require('url');
var util = require('util');
var config = require('config');
Expand All @@ -49,12 +50,13 @@ exports.init = function() {

hrefs.forEach(function(href) {
var options = url.parse(href);
var connection = options.protocol.indexOf('https') > -1 ? https : http;
options.method = 'POST';
options.headers = {
'Content-Type' : 'application/json'
};

var req = http.request(options, function(res) {
var req = connection.request(options, function(res) {

});

Expand Down

0 comments on commit f8b7a4f

Please sign in to comment.