Add title management
Showing
1 changed file
with
7 additions
and
1 deletions
... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
9 | let io; | 9 | let io; |
10 | 10 | ||
11 | const defaultConfig = { | 11 | const defaultConfig = { |
12 | title: 'Express Status', | ||
12 | path: '/status', | 13 | path: '/status', |
13 | spans: [{ | 14 | spans: [{ |
14 | interval: 1, | 15 | interval: 1, |
... | @@ -95,7 +96,12 @@ | ... | @@ -95,7 +96,12 @@ |
95 | 96 | ||
96 | const startTime = process.hrtime(); | 97 | const startTime = process.hrtime(); |
97 | if (req.path === config.path) { | 98 | if (req.path === config.path) { |
98 | res.sendFile(path.join(__dirname + '/index.html')); | 99 | fs.readFile(path.join(__dirname + '/index.html'), function(err, content) { |
100 | content = content.toString().replace(new RegExp(defaultConfig.title, 'g'), config.title); | ||
101 | res.writeHead(200, {'Content-Type': 'text/html'}); | ||
102 | res.write(content); | ||
103 | res.end(); | ||
104 | }); | ||
99 | } else { | 105 | } else { |
100 | onHeaders(res, () => { | 106 | onHeaders(res, () => { |
101 | const diff = process.hrtime(startTime); | 107 | const diff = process.hrtime(startTime); | ... | ... |
-
Please register or sign in to post a comment