使用http node模块(仅限原生模块),我如何使用构造函数重新创建app.listen()和app.get()?
var app = function(opts) {
this.token= opts.token
}
app.prototype.get = function(callback) {
// use request and response of app.listen()
}
app.prototype.active = function(callback) {
// use request and response of app.listen()
// return on callback some manipulate
//request params
}
app.prototype.listen = function() {
// start http or https server
}
导入模块并使用它
var app = require(...)
Var client = new app({
token: 0000
})
client.get(function(error, reply) {})
client.listen()