如何通过管道流在 hapi.js 中回复
How to pipe stream to reply in hapi.js
我正在寻找 hapi 中的并行方法
// 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(?);
}
});
来自另一个question/answer:
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'
}
}
});
我正在寻找 hapi 中的并行方法
// 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(?);
}
});
来自另一个question/answer:
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'
}
}
});