Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

koa如何实现请求转发

$
0
0

express可以这样实现请求转发,但是koa怎么实现呢? var express = require(‘express’); var app = express(); app.get(’/’, function (req, res) { var superagent = require(‘superagent’); var sreq = superagent.get(‘http://sneezryworks.sinaapp.com/ip.php’); sreq.pipe(res); sreq.on(‘end’, function(){ console.log(‘done’); }); }); app.listen(3000);


Viewing all articles
Browse latest Browse all 14821

Trending Articles