Skip to content

Instantly share code, notes, and snippets.

@hns
Created April 26, 2010 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hns/379761 to your computer and use it in GitHub Desktop.
Save hns/379761 to your computer and use it in GitHub Desktop.
Example of async JSGI with ringo/promise
var {defer} = require("ringo/promise");
var {setTimeout} = require("ringo/scheduler");
exports.delayed = function(request) {
var response = defer();
setTimeout(function() {
response.resolve({
status: 200, headers: {}, body: ["Delayed"]
});
}, 1000);
return response.promise;
}
exports.now = function(req) {
var response = defer();
response.resolve({
status: 200, headers: {}, body: ["Now"]
});
return response.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment