问题很简单.我想使用Node.js服务器作为代理来记录,验证和转发HTTP查询到后端HTTP服务器(PUT,GET和DELETE请求).
我应该为此目的使用什么库?我怕我找不到一个.
cho*_*ovy 134
NodeJS支持http.request作为标准模块:http://nodejs.org/docs/v0.4.11/api/http.html#http.request
var http = require('http');
var options = {
host: 'example.com',
port: 80,
path: '/foo.html'
};
http.get(options, function(resp){
resp.on('data', function(chunk){
//do something with chunk
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
Run Code Online (Sandbox Code Playgroud)
您可以使用内置http模块执行此操作http.request().
但是,如果要简化API,可以使用superagent等模块
| 归档时间: |
|
| 查看次数: |
128537 次 |
| 最近记录: |