Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created April 19, 2009 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriskowal/97893 to your computer and use it in GitHub Desktop.
Save kriskowal/97893 to your computer and use it in GitHub Desktop.
var sandboxing = require('chiron/sandbox');
var sandbox = sandboxing.sandbox;
var base = require('chiron/base');
var mime = require('chiron/mime');
exports.main = function (env) {
var log = base.List();
var environment = {'print': log.push};
environment.print = log.push;
var mimeTypes = ['text/plain'];
try {
environment.print('main: ' + require.main + '\n');
environment.print(base.repr(env) + "\n");
environment.print('Negotiated: ' + mime.bestMatch(mimeTypes, env.HTTP_ACCEPT) + "\n");
var moduleId = base.slice(env.PATH_INFO, 1, base.len(env.PATH_INFO))
environment.print(base.repr(moduleId) + "\n");
sandbox(moduleId, environment);
} catch (exception) {
environment.print('Error: ' + (exception.message || exception));
}
return [200, {'Content-type': 'text/plain'}, log.eachIter(function (message) {
return message + "\n";
})];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment