Closed f48vj closed 7 years ago
@fengmk2
I think verify is not belong to co-body logic, it should be another middleware or plugin to do that.
But we can only do it at this middleware if using koa-bodyParser.
If we get raw body before body parser (whatever co-body
koa-body
or koa-bodyparser
) in another middleware, body parser will get nothing and throw an error. we need a way to export the raw body before parse, and koa-body
or koa-bodyparser
are both base on co-body
. so I add verify option to do this, and it provide a chance to decide parse or not parse.
IMO, I'm +1 for verify
option. But we should not repeat code in form.js, json.js and text.js
I think the returnRawBody
option can resolve this problem. closed for now.
Options
verify
The verify option, if supplied, is called as verify(req, str), wherestr
is a string of the raw request body. The parsing can be aborted by throwing an error.Example
Koa