-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Update ContentTypeParser.md #1157
Conversation
docs/ContentTypeParser.md
Outdated
}); | ||
} | ||
``` | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example may be wrong: in fact you can use https://www.fastify.io/docs/latest/ContentTypeParser/#body-parser directly. Maybe we can add and example to parse a json line:
const split2 = require('split2')
fastify.addContentTypeParser('*', (req, done) => {
done(null, pump(req, split2(JSON.parse)));
});
fastify.route({
method: 'POST',
url: '/api/log/jsons',
handler: (req, res) => {
var data = [];
req.body.on('data', d => console.log(d)) // log every incoming object
}
});
or something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should provide an upload example since I feel like most people will be looking for things like uploading files to S3
so it can directly provide them the answer but it is up to you.
Maybe we can fix that example using the approach you provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is actually this plugin for upload so I guess we can give a reference there for upload
docs/ContentTypeParser.md
Outdated
|
||
and then access the core HTTP request directly for piping it where you want: | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 👍 for adding those kind of changes!
Many thanks!
Only a few nits
No problem, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Updated based on #534
Checklist