node-http-server – Diff between revs 30 and 31

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 30 Rev 31
Line 14... Line 14...
14 const winston = require('winston'); 14 const winston = require('winston');
15 const yargs = require('yargs'); 15 const yargs = require('yargs');
16 const dns = require('dns'); 16 const dns = require('dns');
Line 17... Line 17...
17   17  
18 // Local imports. 18 // Local imports.
19 const handler = require( 19 const Handler = require(
20 path 20 path
21 .resolve( 21 .resolve(
22 path.dirname(require.main.filename), 22 path.dirname(require.main.filename),
23 'src', 23 'src',
Line 92... Line 92...
92   92  
93 // Start HTTP server. 93 // Start HTTP server.
94 http.createServer( 94 http.createServer(
95 // authentication, 95 // authentication,
96 (request, response) => 96 (request, response) =>
97 handler.process(config, request, response, root, (logging, result) => { -  
98   97 new Handler().process(config, request, response, root)
99 // Log the message by severity. 98 .on('log', (data) => {
100 log.log(logging.severity, logging.message); -  
101   -  
102 // If no result is to be processed, then terminate the request. 99 log.log(data.severity, data.message);
103 if (typeof result === 'undefined' || result === null) 100 })
104 return; -  
105   101 .on('data', (result) => {
106 // Set the response status. 102 // Set the response status.
107 response.status = result.status; 103 response.status = result.status;
108 // Set the content type and send the data. 104 // Set the content type and send the data.
109 response.setHeader('Content-Type', result.type); 105 response.setHeader('Content-Type', result.type);
110 result.data 106 result.data
111 .on('readable', () => result.data.pipe(response)) 107 .on('readable', () => result.data.pipe(response))
112 .on('end', () => response.end()); 108 .on('end', () => response.end());
113 }) 109 })
114 ).listen(config.net.port, config.net.address, () => { 110 ).listen(config.net.port, config.net.address, () => {
115 log.info('HTTP Server accessible at: http://' + 111 log.info('HTTP Server accessible at: http://' +
116 config.net.address + 112 config.net.address +
117 ':' + 113 ':' +
Line 134... Line 130...
134 { 130 {
135 key: certificates.privateKey, 131 key: certificates.privateKey,
136 cert: certificates.certificate, 132 cert: certificates.certificate,
137 }, 133 },
138 (request, response) => 134 (request, response) =>
139 handler.process(config, request, response, root, (result) => { 135 new Handler().process(config, request, response, root)
140 // Log the message by severity. 136 .on('log', (data) => {
141 log.log(logging.severity, logging.message); 137 log.log(data.severity, data.message);
142   -  
143 // If no result is to be processed, then terminate the request. -  
144 if (typeof result === 'undefined' || result === null) 138 })
145 return; 139 .on('data', (result) => {
146   -  
147 // Set the response status. 140 // Set the response status.
148 response.status = result.status; 141 response.status = result.status;
149 // Set the content type and send the data. 142 // Set the content type and send the data.
150 response.setHeader('Content-Type', result.type); 143 response.setHeader('Content-Type', result.type);
151 result.data 144 result.data
152 .on('readable', () => result.data.pipe(response)) 145 .on('readable', () => result.data.pipe(response))
153 .on('end', () => response.end()); 146 .on('end', () => response.end());
154 }) 147 })
155 ).listen(config.ssl.port, config.ssl.address, () => { 148 ).listen(config.ssl.port, config.ssl.address, () => {
156 log.info('HTTPs Server accessible at: https://' + 149 log.info('HTTPs Server accessible at: https://' +
157 config.ssl.address + 150 config.ssl.address +
158 ':' + 151 ':' +
159 config.ssl.port + 152 config.ssl.port +