/server.js |
@@ -97,20 +97,36 @@ |
// Start HTTP server. |
http.createServer( |
// authentication, |
(request, response) => |
httpcache(request, response, () => { |
new Handler().process(config, request, response, root) |
.on('log', (data) => { |
log.log(data.severity, data.message); |
}) |
.on('data', (result) => { |
response.setHeader('Content-Type', result.type); |
response.writeHead(result.status); |
result.data |
.on('readable', () => result.data.pipe(response)) |
.on('end', () => response.end()); |
}); |
}) |
(request, response) => { |
// Configuration path requested, so send the server configuration if allowed. |
if(config.configuration.enable === true && |
url.parse(request.url, true).path === |
config.configuration.path) { |
const address = request.socket.address(); |
log.info('HTTP Server configuration requested by: ' + |
address.address + ':' + |
address.port |
); |
response.setHeader('Content-Type', 'application/json'); |
response.end(JSON.stringify(config)); |
return; |
} |
|
// Process and cache the resource. |
httpcache(request, response, () => { |
new Handler().process(config, request, response, root) |
.on('log', (data) => { |
log.log(data.severity, data.message); |
}) |
.on('data', (result) => { |
response.setHeader('Content-Type', result.type); |
response.writeHead(result.status); |
result.data |
.on('readable', () => result.data.pipe(response)) |
.on('end', () => response.end()); |
}); |
}); |
} |
).listen(config.net.port, config.net.address, () => { |
log.info('HTTP Server accessible at: http://' + |
config.net.address + |
@@ -135,18 +151,36 @@ |
key: certificates.privateKey, |
cert: certificates.certificate, |
}, |
(request, response) => |
new Handler().process(config, request, response, root) |
.on('log', (data) => { |
log.log(data.severity, data.message); |
}) |
.on('data', (result) => { |
response.setHeader('Content-Type', result.type); |
response.writeHead(result.status); |
result.data |
.on('readable', () => result.data.pipe(response)) |
.on('end', () => response.end()); |
}) |
(request, response) => { |
|
// Configuration path requested, so send the server configuration if allowed. |
if(config.configuration.enable === true && |
url.parse(request.url, true).path === |
config.configuration.path) { |
const address = request.socket.address(); |
log.info('HTTP Server configuration requested by: ' + |
address.address + ':' + |
address.port |
); |
response.setHeader('Content-Type', 'application/json'); |
response.end(JSON.stringify(config)); |
return; |
} |
|
httpcache(request, response, () => { |
new Handler().process(config, request, response, root) |
.on('log', (data) => { |
log.log(data.severity, data.message); |
}) |
.on('data', (result) => { |
response.setHeader('Content-Type', result.type); |
response.writeHead(result.status); |
result.data |
.on('readable', () => result.data.pipe(response)) |
.on('end', () => response.end()); |
}); |
}); |
} |
).listen(config.ssl.port, config.ssl.address, () => { |
log.info('HTTPs Server accessible at: https://' + |
config.ssl.address + |