forked from statusdashboard/statusdashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.js
More file actions
29 lines (27 loc) · 783 Bytes
/
Copy pathhttp.js
File metadata and controls
29 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var http = require('http'),
checkHttpValueResponse = require('../checks/httpValueResponse').execute;
exports.check = function(serviceDefinition, service, callback) {
/**
HTTP module options
*/
var options = {
host: serviceDefinition.host,
port: serviceDefinition.port,
path: serviceDefinition.path,
headers: serviceDefinition.headers
};
/**
HTTP call and error handling
*/
http.get(options, function(response) {
var check = serviceDefinition.callback || checkHttpValueResponse;
service.message = '';
check(response, serviceDefinition, service, callback);
})
.on('error', function(e) {
service.status = "down";
service.statusCode = 0;
service.message = e.message;
callback(service.status, service);
});
};