Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow multiple body parser coexist #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tangxinfa
Copy link

by sync listen events on ctx.req, multiple body parser coexist is safe.

json parser's returnRawBody option can provide untouched request body,
we can use it to do signature validation if required,
but co-body commonly use by high level middlewares,
and not expose a option for user to customize.

allow multiple body parser coexist is a more elegant solution.

by sync listen events on ctx.req, multiple body parser coexist is safe.

json parser's returnRawBody option can provide untouched request body,
we can use it to do signature validation if required,
but co-body commonly use by high level middlewares,
and not expose a option for user to customize.

allow multiple body parser coexist is a more elegant solution.
lib/form.js Outdated
.then(function() {
return raw(inflate(req), opts);
})
return raw(inflate(req), opts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think why we write this code is becaulse inflate will throw in some situation, so we need to wrap it in a promise chain.

test/any.js Outdated
var app = koa();

app.use(function *(next){
this.request.textParser = parse.text(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just check the content-type before call parse[method]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants