提交 7cc554c6 编写于 作者: D Dan Zajdband 提交者: Guillermo Rauch

Fixed hapi example (#795)

上级 ffeeb682
const { Readable } = require('stream')
const pathWrapper = (app, pathName, opts) => ({ raw, query }, hapiReply) =>
app.renderToHTML(raw.req, raw.res, pathName, query, opts)
.then(hapiReply)
function pathWrapper (app, pathName, opts) {
return function (hapiRequest, hapiReply) {
return new Promise((resolve, reject) => {
app.render(hapiRequest.raw.req, hapiRequest.raw.res, pathName, hapiRequest.query, opts)
.catch(error => {
reject(error)
})
.then(() => {
return hapiReply(new Readable().wrap(hapiRequest.raw.res))
})
})
}
}
const defaultHandlerWrapper = app => ({ raw }, hapiReply) =>
app.run(raw.req, raw.res)
function defaultHandlerWrapper (app) {
return function (hapiRequest, hapiReply) {
return new Promise((resolve, reject) => {
app.run(hapiRequest.raw.req, hapiRequest.raw.res)
.catch(error => {
reject(error)
})
.then(() => {
return hapiReply(new Readable().wrap(hapiRequest.raw.res))
})
})
}
}
module.exports = {
pathWrapper,
defaultHandlerWrapper
}
module.exports = { pathWrapper, defaultHandlerWrapper }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册