From 74cb04e7c107707f23a3c8b6e04a2497987e48e3 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 15 Apr 2014 08:39:40 -0700 Subject: [PATCH] refactor --- lib/application.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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