forked from hapijs/hapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtails.js
More file actions
executable file
·47 lines (27 loc) · 725 Bytes
/
tails.js
File metadata and controls
executable file
·47 lines (27 loc) · 725 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Load modules
var Hapi = require('../lib');
// Declare internals
var internals = {};
internals.get = function (request, reply) {
var tail1 = request.tail('tail1');
setTimeout(function () {
console.log(1);
tail1();
}, 5000);
var tail2 = request.tail('tail2');
setTimeout(function () {
console.log(2);
tail2();
}, 2000);
reply('Success!\n');
};
internals.main = function () {
var server = new Hapi.Server(8000);
server.route({ method: 'GET', path: '/', handler: internals.get });
server.start();
// Listen to tail events
server.on('tail', function (request) {
console.log('Wag the dog');
});
};
internals.main();