Closed i5ting closed 7 years ago
async function parseBody(ctx) {
if (enableJson && ((detectJSON && detectJSON(ctx)) || ctx.request.is(jsonTypes))) {
return await parse.json(ctx, jsonOpts);
}
if (enableForm && ctx.request.is(formTypes)) {
return await parse.form(ctx, formOpts);
}
if (enableText && ctx.request.is(textTypes)) {
return await parse.text(ctx, textOpts) || '';
}
return {};
}
when no type matched, 'return {};', developer can't realised the mistake
it should return empty object when request type not match json
, form
or text
.
@dead-horse in co-body https://github.com/cojs/co-body/blob/master/lib/any.js#L44
when not matched will be reject an error code:415, which is right?
co-body is a independent module that you can determined which request should pass to co-body
, but koa-bodyparser
will handle all the requests, it shouldn't throw when type not match.
…ser module