fastify.addContentTypeParser('application/mydata', { parseAs: 'string' }, function (req, body, done) {
try {
//对数据进行处理,
done(null, body)
} catch (err) {
done(err)
}
})
假设body中的数据就是string数据,那么在解析完body数据后(比如转为json数据)为jsondata,调用done(null, jsondata)即可。
在路由中的request.body就是jsondata数据。
- Content-Type fastify Content 类型 Typecontent-type fastify content类型 content-type常见content类型 content-type常用content类型 content-type content类型 文件 content-type content-type content http type content-type content spring header content-type常见content文件 content-type springmvc源码content 39 multipartencoder content-type multipart