Permalink
Browse files

Update code to node v0.1.30 async api.

  • Loading branch information...
1 parent a0c241e commit 02fcba3a368f06c88c3d9deb318533eab44fc910 @creationix committed Feb 26, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 node-router.js
View
@@ -195,16 +195,18 @@ exports.staticHandler = function (req, res, filename) {
return;
}
- fs.readFile(filename, encoding).addCallback(function (data) {
+ fs.readFile(filename, encoding, function (err, data) {
+ if (err) {
+ notFound(req, res, "Cannot find file: " + filename);
+ return;
+ }
body = data;
headers = [ [ "Content-Type" , content_type ],
[ "Content-Length" , body.length ]
];
headers.push(["Cache-Control", "public"]);
callback();
- }).addErrback(function () {
- notFound(req, res, "Cannot find file: " + filename);
});
}

0 comments on commit 02fcba3

Please sign in to comment.