Tag: 内容协商

Hapi.js内容谈判

我想在我的hapi路由中进行内容协商,以便返回客户可以接受的数据types。 快递,我会做这样的事情 res.format({ "text/plain": function(){ res.send("Text Response"); }, "text/html": function(){ res.send("HTML Response"); }, "application/json": function(){ res.json({ message: "JSON Response" }); }, "default": function() { // log the request and respond with 406 res.status(406).send("Not Acceptable"); } }); 是否有内置的方式来做到这一点与hapi? 我浏览了API文档 ,没有看到任何东西。 我坚持滚动我自己的解决scheme?