Permalink
Browse files

Merge pull request #87 from arjansingh/patch-1

Removed 'end' event listener.
  • Loading branch information...
2 parents 36026a3 + eeab04a commit ee1cee6898ac259f7cc7d3a1f1e2d39aa77185de @phstc phstc committed May 1, 2013
Showing with 9 additions and 14 deletions.
  1. +9 −14 examples/file-server.js
View
@@ -3,22 +3,17 @@ var static = require('../lib/node-static');
//
// Create a node-static server to serve the current directory
//
-var file = new(static.Server)('.', { cache: 7200, headers: {'X-Hello':'World!'} });
+var file = new static.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });
require('http').createServer(function (request, response) {
- request.addListener('end', function () {
- //
- // Serve files!
- //
- file.serve(request, response, function (err, res) {
- if (err) { // An error as occured
- console.error("> Error serving " + request.url + " - " + err.message);
- response.writeHead(err.status, err.headers);
- response.end();
- } else { // The file was served successfully
- console.log("> " + request.url + " - " + res.message);
- }
- });
+ file.serve(request, response, function (err, res) {
+ if (err) { // An error as occured
+ console.error("> Error serving " + request.url + " - " + err.message);
+ response.writeHead(err.status, err.headers);
+ response.end();
+ } else { // The file was served successfully
+ console.log("> " + request.url + " - " + res.message);
+ }
});
}).listen(8080);

0 comments on commit ee1cee6

Please sign in to comment.