refactor
This commit is contained in:
parent
4e44c1c49e
commit
74cb04e7c1
1 changed files with 3 additions and 6 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
if (null == body) {
|
||||
// status body
|
||||
if (null == 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
|
||||
|
|
Loading…
Reference in a new issue