Skip to content

Commit

Permalink
move execute_sjs out of closure
Browse files Browse the repository at this point in the history
  • Loading branch information
mhansen committed Jul 10, 2010
1 parent fc006ba commit bc45304
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/antinode.js
Expand Up @@ -192,22 +192,23 @@ function handle_request(path, req, resp) {
finish(resp);
}

function execute_sjs() {
fs.readFile(path, 'utf8', function(err, script) {
try {
if (err) throw err;
var handler = {
log: log,
require: require
};
Script.runInNewContext(script, handler, path);
handler.handle(req, resp);
}
catch (e) {
server_error("Error executing server script "+path+": "+e);
}
});
}
}

function execute_sjs(path, req, resp) {
fs.readFile(path, 'utf8', function(err, script) {
try {
if (err) throw err;
var handler = {
log: log,
require: require
};
Script.runInNewContext(script, handler, path);
handler.handle(req, resp);
}
catch (e) {
server_error("Error executing server script "+path+": "+e);
}
});
}

function finish(resp) {
Expand Down

0 comments on commit bc45304

Please sign in to comment.