Im looking for the parllel method in hapi
// Express + Request exmaple
function(req, res){
request('http://example.com/image.png').pipe(res);
}
How to pipe a response in hapi ?
server.route({
method: "*",
path: "/api/results/{date}",
handler: (request, reply) => {
//????reply(?);
}
});
From another question/answer:
function (request, reply) {
Request('http://example.com/image.png')
.on('response', function (response) {
reply(response);
});
}
If you only need to forward an upstream response, you can just use a proxy handler via the h2o2 plugin:
server.route({
method: 'GET',
path: '/upstream/file',
handler: {
proxy: {
uri: 'http://example.com/image.png'
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.