proto.toListener = function () {
var body = this.body
var middleware = this.middleware.slice()
return function requestListener (req, res) {
var ctx = createContext(app, req, res, onerror, thunks({
debug: debug,
onstop: onstop,
onerror: onerror
}))
ctx.thunk.seq.call(ctx, middleware)(function () {
return body.call(this, this.thunk)
})(function () {
return this.thunk.seq.call(this, this.onPreEnd)(respond)
})
}
}
Toa / thunks 组合异步(同步)业务逻辑原理示意