Closed amitguptagwl closed 6 years ago
I do not understand what is the problem, what do you want to achieve, and how we can help. Can you please articulate further?
Sorry for the confusing language. I've got the answer while exploring other examples. Many thanks for your quick response.
I'm trying to write a body parser which converts nimn data format to js object. For this, I need to know the object structure of target json which can be different for each route. So how can I pass options with every route so that body parser can parse request payload to js obj accordingly?
const opts = {
schema: {}
};
fastify.get('/', opts, (request, reply) => {
//write some code here
})
As per above snippets, I want to access opts in body parser plugin.
You should really post this issue in the Fastify repo. This is just a little utility to help writing plugins.
sure thanks. I'll do
should I ask in fastify or fastify/help?
Issues should only be posted in this repository after you have been able to reproduce them and confirm that they are a bug or incorrect/missing information in the docs.
For all other questions, requests, help resolving an issue, or if you are not sure if this is the right place, please do not open an issue here. Instead, ask a question in our help repository or try to find a solution in the community Gitter Chat.
I would go for the main repo, this functionality is not there. We only support schema-based behavior through https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md#schema-compiler, but it's JSON-only.
Exactly. I believe both functionalities should be implemented in the same way, so it can facilitate 3rd party plugins too.
I was trying to write a body parser to support multiple content types. To parse nimn to json, I need to pass simplified object structure to the parser which is accepted by particular route.