diff --git a/lib/application.js b/lib/application.js index 833af91..2631c51 100644 --- a/lib/application.js +++ b/lib/application.js @@ -168,6 +168,7 @@ function *respond(next) { yield *next; + // allow bypassing koa if (false === this.respond) return; var res = this.res; @@ -188,21 +189,17 @@ function *respond(next) { return res.end(); } + // status body if (null == body) { - // status body this.type = 'text'; body = status[code]; if (body) this.length = Buffer.byteLength(body); return res.end(body); } - // Buffer body + // responses if (Buffer.isBuffer(body)) return res.end(body); - - // string body if ('string' == typeof body) return res.end(body); - - // Stream body if (body instanceof Stream) return body.pipe(res); // body: json