mcavage/node-restify — pull request #245 by oroce (2012-11-10 13:52:54+00:00)
Title: Async formatters

Async formatters you could use xmlwriter class, render templates if you need.

You can do this:

formatter: {
"application/json": function(req,res,body,cb){
if( async ){
setTimeout(function(){
cb( null, "your async content" );
}, 5000 );
return this;
}
else{
return whatYouWantExceptThis; //undefined,null, "", Object, Buffer;
}
}
}

If you want to use it asynchronously, you have to return this, if you return anything else it'll be threated as synchronous.