Example #1
0
module.exports = function(){
	var cofy = require('cofy');
	var request = require('request');
	request.$request = cofy.fn(request);
	cofy.object(request,true,['put','patch','post','head','del','get']);
	return request;
};
Example #2
0
app.use(json()).use(function *(next) {
    var c = request.createClient('http://play.youku.com/');
    var rsp = (yield cofy.fn(c.get, true, c)(this.path.slice(1) + '?' + this.querystring))[1];
    rsp.data.user.vip = true;
    this.body = JSON.stringify(rsp);
    yield next;
});
Example #3
0
module.exports = function(){
	var cofy = require('cofy');
	var amqp = require('amqp');
	amqp.$createConnection = cofy.fn(amqp.createConnection ,false , amqp);
	cofy.class(amqp.Connection);
	cofy.class(require('amqp/lib/exchange.js') , true , ['bind','publish','unbind','bind_headers']);
	cofy.class(require('amqp/lib/queue.js') , true , ['bind']);
	amqp.Connection.prototype.$ready = function() {
		var _this = this;
		return function(done){
			_this.on('ready' , function(){
				done();
			});
			_this.on('error',function(e){
				done(e);
			});
		};
	};
};