如何pipe道stream在hapi.js回复
我在寻找hapi的parllel方法
// Express + Request exmaple function(req, res){ request('http://example.com/image.png').pipe(res); }
如何在hapipipe道响应?
server.route({ method: "*", path: "/api/results/{date}", handler: (request, reply) => { //????reply(?); } });
从另一个问题/答案:
function (request, reply) { Request('http://example.com/image.png') .on('response', function (response) { reply(response); }); }
如果您只需要转发上游响应,则可以通过h2o2插件使用代理处理程序:
server.route({ method: 'GET', path: '/upstream/file', handler: { proxy: { uri: 'http://example.com/image.png' } } });