koajs / koa-body

koa body parser middleware
MIT License
950 stars 130 forks source link

Make request parsing accept the returnRawBody option inorder to return the raw string #113

Closed thuitaw closed 5 years ago

thuitaw commented 6 years ago

This PR adds an option for the koa-body middleware to accept the returnRawBody parameter, that can then be passed on to the co-body library so that on parsing urlencoded parameters, one has control over whether to return the original raw urlencoded string alongside the parsed urlencoded string.

Implementation in co-body: link (code)

co-body [documentation] (https://github.com/cojs/co-body)

Use Case:

Consider the case of slack's [api] (https://api.slack.com/docs/verifying-requests-from-slack) when verifying hmac requests, part of the hashed data inlcudes the raw urlencoded string. There was previously no way of getting this with koa-body

MarkHerhold commented 6 years ago

LGTM. Will merge and release tonight

JackCuthbert commented 6 years ago

@thuitaw How's this one going? I'm currently depending on your fork for a project of mine that implements your exact use case. Happy to help out if I can.

thuitaw commented 6 years ago

@thuitaw How's this one going? I'm currently depending on your fork for a project of mine that implements your exact use case. Happy to help out if I can.

@JackCuthbert I'm really sorry, this completely slipped my mind. I'll update the tests as soon as possible so that we can close this out.

thuitaw commented 6 years ago

@thuitaw How's this one going? I'm currently depending on your fork for a project of mine that implements your exact use case. Happy to help out if I can.

@JackCuthbert I'm really sorry, this completely slipped my mind. I'll update the tests as soon as possible so that we can close this out.

But just to be clear @JackCuthbert this completely works. I just need to update the tests so that I can be merged back to mainstream. I'm using an internal fork of this as well

galaa2011 commented 5 years ago

When this can be released?

MarkHerhold commented 5 years ago

@galaa2011 When there are tests.

MarkHerhold commented 5 years ago

Closing in favor of #125