MCPcopy Index your code
hub / github.com/assertible/lambda-cloudwatch-slack / postMessage

Function postMessage

index.js:10–40  ·  view source on GitHub ↗
(message, callback)

Source from the content-addressed store, hash-verified

8var baseSlackMessage = {}
9
10var postMessage = function(message, callback) {
11 var body = JSON.stringify(message);
12 var options = url.parse(hookUrl);
13 options.method = 'POST';
14 options.headers = {
15 'Content-Type': 'application/json',
16 'Content-Length': Buffer.byteLength(body),
17 };
18
19 var postReq = https.request(options, function(res) {
20 var chunks = [];
21 res.setEncoding('utf8');
22 res.on('data', function(chunk) {
23 return chunks.push(chunk);
24 });
25 res.on('end', function() {
26 var body = chunks.join('');
27 if (callback) {
28 callback({
29 body: body,
30 statusCode: res.statusCode,
31 statusMessage: res.statusMessage
32 });
33 }
34 });
35 return res;
36 });
37
38 postReq.write(body);
39 postReq.end();
40};
41
42var handleElasticBeanstalk = function(event, context) {
43 var timestamp = (new Date(event.Records[0].Sns.Timestamp)).getTime()/1000;

Callers 1

processEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected