node-http-server – Diff between revs 15 and 29

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 15 Rev 29
Line 52... Line 52...
52 }) 52 })
53 .help() 53 .help()
54 .argv 54 .argv
Line 55... Line 55...
55   55  
-   56 // Create various logging mechanisms.
-   57 // RFC5424 - { emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7 }
56 // Create various logging mechanisms. 58 winston.setLevels(winston.config.syslog.levels);
57 const log = new winston.Logger({ 59 const log = new winston.Logger({
58 transports: [ 60 transports: [
59 new winston.transports.File({ 61 new winston.transports.File({
60 level: 'info', 62 level: 'info',
Line 90... Line 92...
90   92  
91 // Start HTTP server. 93 // Start HTTP server.
92 http.createServer( 94 http.createServer(
93 // authentication, 95 // authentication,
94 (request, response) => 96 (request, response) =>
-   97 handler.process(config, request, response, root, (result) => {
95 handler.process(config, request, response, root, (error, level) => { 98
96 switch (level) { 99 // Log the message by severity.
97 case handler.error.level.INFO: 100 log.log(result.severity, result.message);
98 log.info(error); 101 if(result.status)
-   102 response.status = result.status;
99 break; 103
100 case handler.error.level.WARN: 104 // If no data stream is made available or the content type is not
-   105 // set then there is no further reason to bother with the request.
-   106 if(typeof result.data === 'undefined' || result.data === null ||
101 log.warn(error); 107 typeof result.type === 'undefined' || result.type === null)
-   108 return;
102 break; 109
103 case handler.error.level.ERROR: 110 // Set the content type and send the data.
104 log.error(error); 111 response.setHeader('Content-Type', result.type);
105 break; 112 result.data
-   113 .on('open', () => result.data.pipe(response));
106 } 114
107 }) 115 })
108 ).listen(config.net.port, config.net.address, () => { 116 ).listen(config.net.port, config.net.address, () => {
109 log.info('HTTP Server accessible at: http://' + 117 log.info('HTTP Server accessible at: http://' +
110 config.net.address + 118 config.net.address +
Line 128... Line 136...
128 { 136 {
129 key: certificates.privateKey, 137 key: certificates.privateKey,
130 cert: certificates.certificate, 138 cert: certificates.certificate,
131 }, 139 },
132 (request, response) => 140 (request, response) =>
133 handler.process(config, request, response, root, (error, level) => { 141 handler.process(config, request, response, root, (result) => {
134 switch (level) { 142 // Log the message by severity.
135 case handler.error.level.INFO: 143 log.log(result.severity, result.message);
136 log.info(error); 144 if(result.status)
137 break; 145 response.status = result.status;
-   146
138 case handler.error.level.WARN: 147 // If no data stream is made available or the content type is not
139 log.warn(error); 148 // set then there is no further reason to bother with the request.
-   149 if(typeof result.data === 'undefined' || result.data === null ||
-   150 typeof result.type === 'undefined' || result.type === null)
140 break; 151 return;
-   152
141 case handler.error.level.ERROR: 153 // Set the content type and send the data.
142 log.error(error); 154 response.setHeader('Content-Type', result.type);
143 break; 155 result.data
144 } 156 .on('open', () => result.data.pipe(response));
145 }) 157 })
146 ).listen(config.ssl.port, config.ssl.address, () => { 158 ).listen(config.ssl.port, config.ssl.address, () => {
147 log.info('HTTPs Server accessible at: https://' + 159 log.info('HTTPs Server accessible at: https://' +
148 config.ssl.address + 160 config.ssl.address +
149 ':' + 161 ':' +