我在hapi 中寻找parllel方法
// Express + Request exmaple
function(req, res){
request('http://example.com/image.png').pipe(res);
}
如何在hapi中发送响应?
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);
});
}
https://stackoverflow.com/a/31222563/2573244
如果你只需要转发上游响应,你可以通过h202插件使用代理处理程序:
server.route({
method: 'GET',
path: '/upstream/file',
handler: {
proxy: {
uri: 'http://example.com/image.png'
}
}
});