Comments (13)
yep i agree. though, really, the issue is with the .is()
function. or perhaps i'm using it incorrectly.
from body-parsers.
are these custom media types using the +json
suffix?
from body-parsers.
It's my understanding that they should carry the +json
suffix to be json formatted
from body-parsers.
For my case, yes, I use +json
suffix to specify format, as is good practice. .is()
should pick that up, althou it doesn't (so that's another issue). But in any case, it is just good practice to use +json
suffix, it is not mandatory. There is nowhere specified, that application/x.cucumber
cannot be json formatted, the contract between server and client specifies that. request.json()
should not make that decision for you.
Just my opinion.
from body-parsers.
@jonathanong the issue is that the user does not have the ability to influence the line https://github.com/koajs/body-parsers/blob/master/index.js#L28 , so they have no way to let whatever Content-Type be interpreted as json that they want.
from body-parsers.
@dougwilson should changing it to +json
make it always work?
from body-parsers.
You can make it ['json', '+json']
, but that still won't help someone who wants to use Content-Type: application/x-my-type
, especially if they don't have control over it.
from body-parsers.
I think we need a way to pass an optional type to the json parsing bit then?
from body-parsers.
yep.
@dougwilson how was making a generic body parsing module? was kind of waiting for that, at least the body reading part.
from body-parsers.
I would still recommend just removing the check, it is redundant if you follow example from Koala:
switch (this.request.is('json', 'urlencoded', 'multipart', 'image/*')) {
case 'json':
var body = yield* this.request.json();
break;
case 'urlencoded':
var body = yield* this.request.urlencoded();
break
it means, that the check will be performed for json always twice. And more, if you allow passing an argument, the argument will have to be duplicated for both is
and json
. Redundancy.
Just consider it. Thanks.
from body-parsers.
yup i don't see why not. hopefully i'll get to it tonight
from body-parsers.
Great, thanks!
from body-parsers.
Great! LGTM.
from body-parsers.
Related Issues (13)
- Common generic body bufferring HOT 1
- remove `fs-cp`? HOT 4
- docs
- improve test coverage
- An in-range update of raw-body is breaking the build 🚨 HOT 2
- An in-range update of mocha is breaking the build 🚨 HOT 3
- An in-range update of koa is breaking the build 🚨
- An in-range update of koa is breaking the build 🚨 HOT 8
- use eslint-config-koa
- Version 10 of node.js has been released
- An in-range update of supertest is breaking the build 🚨 HOT 4
- expose functional versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from body-parsers.