如果是method = "post",我如何使rest[method]扩展到rest.post(uri, body).then(..
function proxyUrl() {
return function(req, res, next) {
proxyFound = url.some(function (element) {
if (req.url == element) {
method = req.method.toLowerCase();
body = req.body;
//get host to prozy to
var host;
arrayProxies.some(function (hostName) {
if (proxyList[hostName] == element) {
host = hostName;
return true;
}
});
//Make Call...do proxy
uri = 'https://'+host;
console.log(method);
rest[method](uri, body).then(
function(response) {
res.send(response);
}, function(error) {
res.send(error.statusCode, error);
});
}
return true;
});发布于 2014-07-12 19:52:48
如果是method = "post",那么它就是rest[method](uri, body).then(… --就像代码中有它一样。括号表示法与往常一样适用于方法调用。
https://stackoverflow.com/questions/24716691
复制相似问题