Im che cerca il metodo parllel in hapiCome tubo di flusso a rispondere per hapi.js
// Express + Request exmaple
function(req, res){
request('http://example.com/image.png').pipe(res);
}
Come tubo di una risposta in Hapi?
server.route({
method: "*",
path: "/api/results/{date}",
handler: (request, reply) => {
//????reply(?);
}
});
Non sono sicuro che sia possibile. Richiede supporto per gli stream2 api? Dalla documentazione di hapi: 'Oggetto stream (Nota: qualsiasi oggetto Stream deve essere compatibile con l'API" streams2 "e non essere in objectMode)' http://hapijs.com/api#reply-interface – Clarkie
L'ho fatto con il modulo aws-sdk: 'reply (s3.getObject (params) .createReadStream());' – Clarkie
server.route ({ \t metodo: "*", \t percorso: "/ api/results/{date}" , \t gestore: (req, rispondere) => { \t \t var fs = richiedono ('FS'); \t \t var = FILESTREAM fs.createWriteStream (' Doron ./ '); \t \t richiesta (' http : //google.com/doodle.png ') .pipe (fileStream); \t \t \t risposta (fileStream); \t \t} }); questo lancia l'eccezione seguente Debug: internal, implementation, error Errore: Stream deve avere un'interfaccia leggibile streams2 –